Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp2897016rwl; Mon, 27 Mar 2023 06:49:23 -0700 (PDT) X-Google-Smtp-Source: AKy350ZC7USjNa5OmiJRl7LRtKfzTmt6YOf4VDU5cphZEnX24YrhS8yG2foD7hvvAIXQDQToCJ9s X-Received: by 2002:a05:6402:1390:b0:502:2382:5c24 with SMTP id b16-20020a056402139000b0050223825c24mr10479989edv.39.1679924963256; Mon, 27 Mar 2023 06:49:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679924963; cv=none; d=google.com; s=arc-20160816; b=TB/t9JbeENpxWtnFVf8qdiGo4G3yQ7kXexd+cPo3BmYEIqaIrED5tk1hjMVcXMTKZX V8MhMwWJvWtfzk5CDuW8YPljJz5U73poegOyQXwcSKeA8s0CI9zJEaetS06a5av0YQX7 sKNnlqiC6yLpXZSJ9uzibLCLkXGF3I6zEZz25TZly5OnUe6bilKp9mbreY99gkNDbedc inllqvWamR3roHmOivM0V5B//F+9BkbBfYOX8OFjJ+WyYP2QoVx9o3eq0nqeicJxHdSI RE+qcyjfRyxUCU/dJSYLtMHpWZdjJaiaX0WiQ6SP0lVQdPmT3+2FMwfo+aNJCZn2w8Oo SxSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8roPEj8EC7N26IRrzr+bd955hd7RnrTWNtsdCvtyS6s=; b=CvIWQ1AlBLP7zOBDrQ2+xKKfrxpjKCnWlvGP3fEjsFSE4IPHkW5yAII+uXjL4Y2P5x eIR/wPAdl2DoQ0gbuQXhFXmAAVrN1Yf7D2smDWMBKbJFfCiZBMpKl09KIhg8fq7V/XCF cwjvgOErAkMab9mMtWEV5Nwkh7wxr/zI+xqH6x29LX3nqhHTRUyv1eD85sR+UVuQZJNR tmKVXTIHYH5pHh0uUaB7JL34rcUx5f6IXGz3L6Bx1WDj3P9j1L7bAOS9yFphugsBvZ+5 ijxdjXmJia2FIY2gvqJ4jbj0JORaQASQehGf5E1XrfRve+xJeGwqLdWPa4uVTZp6CMyY IRNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=soLiZeMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t1-20020aa7d701000000b00501dcf278b0si17942980edq.271.2023.03.27.06.48.57; Mon, 27 Mar 2023 06:49:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=soLiZeMa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbjC0Nnb (ORCPT + 99 others); Mon, 27 Mar 2023 09:43:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229546AbjC0Nna (ORCPT ); Mon, 27 Mar 2023 09:43:30 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8A403AB6 for ; Mon, 27 Mar 2023 06:43:29 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 830551FD72; Mon, 27 Mar 2023 13:43:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1679924608; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=8roPEj8EC7N26IRrzr+bd955hd7RnrTWNtsdCvtyS6s=; b=soLiZeMaIxj/bgarNhrTFIq8Pw6Vxeq6Jh5s7kTHsfs3GgeDeYFC6V2u5rlEqjbWeaD8Yg 9EnZsaBANMRQZJeQ0h3gDFWDSoA7VS+pRuLiNmoEXKpkgrkd+kRj/Ka8EDza+60HAGCA+q HR7ABBaSn+yWkc2nHv44l2S4+U8Doqw= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 6166C13329; Mon, 27 Mar 2023 13:43:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id mZd1FYCdIWTpeAAAMHmgww (envelope-from ); Mon, 27 Mar 2023 13:43:28 +0000 Date: Mon, 27 Mar 2023 15:43:27 +0200 From: Michal Hocko To: Mike Rapoport Cc: linux-mm@kvack.org, Andrew Morton , Dave Hansen , Peter Zijlstra , Rick Edgecombe , Song Liu , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, x86@kernel.org Subject: Re: [RFC PATCH 1/5] mm: intorduce __GFP_UNMAPPED and unmapped_alloc() Message-ID: References: <20230308094106.227365-1-rppt@kernel.org> <20230308094106.227365-2-rppt@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 25-03-23 09:38:12, Mike Rapoport wrote: > On Fri, Mar 24, 2023 at 09:37:31AM +0100, Michal Hocko wrote: > > On Wed 08-03-23 11:41:02, Mike Rapoport wrote: > > > From: "Mike Rapoport (IBM)" > > > > > > When set_memory or set_direct_map APIs used to change attribute or > > > permissions for chunks of several pages, the large PMD that maps these > > > pages in the direct map must be split. Fragmenting the direct map in such > > > manner causes TLB pressure and, eventually, performance degradation. > > > > > > To avoid excessive direct map fragmentation, add ability to allocate > > > "unmapped" pages with __GFP_UNMAPPED flag that will cause removal of the > > > allocated pages from the direct map and use a cache of the unmapped pages. > > > > > > This cache is replenished with higher order pages with preference for > > > PMD_SIZE pages when possible so that there will be fewer splits of large > > > pages in the direct map. > > > > > > The cache is implemented as a buddy allocator, so it can serve high order > > > allocations of unmapped pages. > > > > Why do we need a dedicated gfp flag for all this when a dedicated > > allocator is used anyway. What prevents users to call unmapped_pages_{alloc,free}? > > Using unmapped_pages_{alloc,free} adds complexity to the users which IMO > outweighs the cost of a dedicated gfp flag. Aren't those users rare and very special anyway? > For modules we'd have to make x86::module_{alloc,free}() take care of > mapping and unmapping the allocated pages in the modules virtual address > range. This also might become relevant for another architectures in future > and than we'll have several complex module_alloc()s. The module_alloc use is lacking any justification. More context would be more than useful. Also vmalloc support for the proposed __GFP_UNMAPPED likely needs more explanation as well. > And for secretmem while using unmapped_pages_alloc() is easy, the free path > becomes really complex because actual page freeing for fd-based memory is > deeply buried in the page cache code. Why is that a problem? You already hook into the page freeing path and special case unmapped memory. > My gut feeling is that for PKS using a gfp flag would save a lot of hassle > as well. Well, my take on this is that this is not a generic page allocator functionality. It is clearly an allocator on top of the page allocator. In general gfp flags are scarce and convenience argument usually fires back later on in hard to predict ways. So I've learned to be careful here. I am not saying this is a no-go but right now I do not see any acutal advantage. The vmalloc usecase could be interesting in that regards but it is not really clear to me whether this is a good idea in the first place. -- Michal Hocko SUSE Labs