From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FE4DC77B7D for ; Thu, 18 May 2023 16:33:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 77F67900005; Thu, 18 May 2023 12:33:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72FDA900004; Thu, 18 May 2023 12:33:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F715900005; Thu, 18 May 2023 12:33:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 505D4900004 for ; Thu, 18 May 2023 12:33:54 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 0BA34C0835 for ; Thu, 18 May 2023 16:33:54 +0000 (UTC) X-FDA: 80803922388.12.DEBBF95 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf05.hostedemail.com (Postfix) with ESMTP id F0D47100023 for ; Thu, 18 May 2023 16:33:51 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gWYGBz03; spf=pass (imf05.hostedemail.com: domain of song@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=song@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684427632; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=FYRtl51h2PpkvHHUF8fJIn6M+yXeV1gY79q3gLdai5g=; b=zOGRHXeQWRhgA0rjVxv3VLxC/PPzZXVl6cE0TyGqfsXFMjgZNZ9pyjWIRyaj3O8pAh3Q34 sMvQIOlFXI60J6KeLEfPEmC4sXTSjRFFcR50rbm7LpZlsMU/d13GUeJnZ7r6yCC1b88pA6 d/u/RQljuyfRHLRh4pooD7kPU5JIkv8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684427632; a=rsa-sha256; cv=none; b=7hNTYGSM8cuxQfnFoITF4G8kzeTZhEfz7bddpHbydSkW2RwFj5CO+Kt+Mlb2kVsNyH1BgX XmwNvRRpQCgwruXzvCPT8MbaP9GauRwcpj2swWNPgF0d9y3WreuDTW2vAFSkXHmPSZgUW8 W3TvM+5jxUBEeZDxxHDEZravk4LDA8A= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gWYGBz03; spf=pass (imf05.hostedemail.com: domain of song@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=song@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id ED3C8650D1 for ; Thu, 18 May 2023 16:33:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C8AEC433A0 for ; Thu, 18 May 2023 16:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684427615; bh=WcLiBzhFbhnqT4iTF0sRkM/Vim1CG6TRTNawjkcfL6Q=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=gWYGBz03+1JvsYNxN/T6wLtrtDbtZAR5gXCydsklR7zhH/e9tcl7mPoVIrBZGrE7T UI2pAPLz7PeSEiW0/HcI4FfefJiXGgBOOdgZIkYtVr5kPLeckxUDMsnmMuKpuEGbGu 1IB1fPx1tiwc5CNusDBD4hYTQSw6/QTuLOnGSyDUO/Xfo9E0Us1WGdJhiTyzTBGYBu 6DzI7kkngwE6xY0jte314SoLQLcXGkrn+TS+ExsUxJQzx81GH0g+Sh5f7mxyRQbzHd FmL6tbz9LtyHGJ/FcBb0cz0kRSb43W2HDH4P+DOsLYADhTebSJPQwf8W7yx05BJsRj qNTVkRBtjwlmQ== Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-4efd6e26585so2555859e87.1 for ; Thu, 18 May 2023 09:33:35 -0700 (PDT) X-Gm-Message-State: AC+VfDw4OE7su79I3gG5lLWlpeGJPomlukzgNYfulFrsO9mGa24m6fyr b/ze9MquecJIQ0KSQ5bKiTUmXNuIWBsyxkxOueE= X-Google-Smtp-Source: ACHHUZ52GC0BshUWnwslDjM4lCSENObwVMvDSQYPg8cSAvRRia2PtEIQI6fWg6BonMCxpJahZ/WXWxY6e/9fQPSxlRo= X-Received: by 2002:ac2:44ca:0:b0:4f3:87d7:f7a4 with SMTP id d10-20020ac244ca000000b004f387d7f7a4mr1420356lfm.62.1684427613322; Thu, 18 May 2023 09:33:33 -0700 (PDT) MIME-Version: 1.0 References: <20230308094106.227365-1-rppt@kernel.org> <20230308094106.227365-2-rppt@kernel.org> <20230518152354.GD4967@kernel.org> In-Reply-To: <20230518152354.GD4967@kernel.org> From: Song Liu Date: Thu, 18 May 2023 09:33:20 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/5] mm: intorduce __GFP_UNMAPPED and unmapped_alloc() To: Mike Rapoport Cc: Kent Overstreet , linux-mm@kvack.org, Andrew Morton , Dave Hansen , Peter Zijlstra , Rick Edgecombe , Thomas Gleixner , Vlastimil Babka , linux-kernel@vger.kernel.org, x86@kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X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qcvkGTQBoL5FE0BVgg2OVA3 8d2C3l0E NdH80ABO0ve49tUNpj1VVDG+Y6sAeRd1zmrRLhHsMh1E18MTAgqJNCq7iDwquxPJtRozORHFqfKs7+t9yeftdOiLV/4td7epexlLbXfIbLM3Nn4JS1uq6CWBvXlK7KEo97w+QZijulQPSB2x3FvQbCTVg3Hn7emYKvDo9z799HhDcL5LrhGlq7hFNnuPq3rPQmKeRlrt0U7gX2HWFxcqfKVYNBm2OKJHpKLfziZx5PhguJU6ZeEv9CPW7SBBV0AHLOIxlSSuAMl+bFVoYELFI70FI2Gij60kAcgiqzDO5PXki+vOoNZULfkuuQfTP28tzuXUvps9iD1N/nFHanyLf6GNDFoBKmNEcyl3dMNpDGC85MFVcj8ECmHpCtmHCESC2mdRrJcm4U/9qAEB5klbrgJZBye+1c/E3EJNKXu2PAtB88ec= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, May 18, 2023 at 8:24=E2=80=AFAM Mike Rapoport wro= te: > > On Wed, May 17, 2023 at 11:35:56PM -0400, Kent Overstreet wrote: > > On Wed, Mar 08, 2023 at 11:41:02AM +0200, 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 thes= e > > > 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 p= ages. > > > > > > This cache is replenished with higher order pages with preference for > > > PMD_SIZE pages when possible so that there will be fewer splits of la= rge > > > pages in the direct map. > > > > > > The cache is implemented as a buddy allocator, so it can serve high o= rder > > > allocations of unmapped pages. > > > > So I'm late to this discussion, I stumbled in because of my own run in > > with executable memory allocation. > > > > I understand that post LSF this patchset seems to not be going anywhere= , > > but OTOH there's also been a desire for better executable memory > > allocation; as noted by tglx and elsewhere, there _is_ a definite > > performance impact on page size with kernel text - I've seen numbers in > > the multiple single digit percentage range in the past. > > > > This patchset does seem to me to be roughly the right approach for that= , > > and coupled with the slab allocator for sub-page sized allocations it > > seems there's the potential for getting a nice interface that spans the > > full range of allocation sizes, from small bpf/trampoline allocations u= p > > to modules. > > > > Is this patchset worth reviving/continuing with? Was it really just the > > needed module refactoring that was the blocker? > > As I see it, this patchset only one building block out of three? four? > If we are to repurpose it for code allocations it should be something lik= e > > 1) allocate 2M page to fill the cache > 2) remove this page from the direct map > 3) map the 2M page ROX in module address space (usually some part of > vmalloc address space) > 4) allocate a smaller chunk of that page to the actual caller (bpf, > modules, whatever) > > Right now (3) and (4) won't work for modules because they mix code and da= ta > in a single allocation. I am working on patches based on the discussion in [1]. I am planning to send v1 for review in a week or so. Thanks, Song [1] https://lore.kernel.org/linux-mm/20221107223921.3451913-1-song@kernel.o= rg/ [...]