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 BEB1CC77B7A for ; Thu, 18 May 2023 20:51:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 37503900004; Thu, 18 May 2023 16:51:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 324F6900003; Thu, 18 May 2023 16:51:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2155A900004; Thu, 18 May 2023 16:51:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 13409900003 for ; Thu, 18 May 2023 16:51:29 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 8A72F1C6FEA for ; Thu, 18 May 2023 20:51:26 +0000 (UTC) X-FDA: 80804571372.12.A7BB70A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 87CA74000A for ; Thu, 18 May 2023 20:51:24 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TbsWqD+7; spf=pass (imf11.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=1684443084; 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=Mcohg/XV/wrFIOA2dbWQp4WbXXb3DOZC5jV/ZprWGFE=; b=3fJ/LmQPuTUyDY+iFvjPjSthAZSLuJ3bCtscf9g+yZQNFKu/IDolEGFj9hT4fGcYtPYPmO lQnrz5SHc50qahVVjDoQrqkyWKTqLfF4uELBA1qPXmdGvpZP7EY1cVhfz4cxTsHfexO6Z3 Inq7/eFdZevycUieAqNjlGr113WetLE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684443084; a=rsa-sha256; cv=none; b=tDVMKMXK8VyRqawHkUog49+BVCDMkA8+MFxqXDoN2iHIOw9Io3Ouane+NJen82by0ob8+C h1tnBZ+Bry7S5tRJpLAOUeX1zaVNxOJmjr3KTngpRLW6u7M0qkQ1dBkc6vYcYn6kWcrtEC SfukKBKuTbUFqWKz46+rVqpWK55kZA8= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TbsWqD+7; spf=pass (imf11.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 91A9B6522D for ; Thu, 18 May 2023 20:51:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7ACD8C433A4 for ; Thu, 18 May 2023 20:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684443082; bh=Mcohg/XV/wrFIOA2dbWQp4WbXXb3DOZC5jV/ZprWGFE=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=TbsWqD+7b4kGi8NsWgROO6O/Pg+2Iwrj15TYHLq1bbeELPriTHIdqkvLswmNAS6Dj SPn0mKlINpuG6hfj44KfMIItwAO/E2AkD39atTJGumGCc/SyeCHLUbSjQ/FnAJuu2c wbPRCQb6Z9nGI9maqjChMf20UcDuSCN7ooLRGJDf2Q8KnkukixjTkJCQn+DeSSOwU+ VI7qIhIYN541GRrb3XjZZ1ynUgGVkK+N7wtfaFg9SE+9PEhazXxnf/ZHw29L55jpM+ +FCBp3GRPnAO/x4Mzn5t7Bygy/T5tMt1wVcx/GQCiMp7b6U2kWSDBHxmHFQjyqyAYE 9MmEzJ6hjv2pQ== Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2af177f12d1so12861891fa.0 for ; Thu, 18 May 2023 13:51:22 -0700 (PDT) X-Gm-Message-State: AC+VfDyp3qJ+c8XURX7pZvSmks4KVoWbBXnBg10xGErS38DIxCHxsBwd JKaarRx6NkY8GDRVf9N02wnRxWUL3Pzm/WotkrI= X-Google-Smtp-Source: ACHHUZ5OEA6kaXJKZOVU8MfSLnsAK59aRs1t/9/zhbRzGVU8wITXI6PQO0WrhEk35bpZ+lXbRRWq44o636fx3BTcX2s= X-Received: by 2002:a19:ad02:0:b0:4f2:509b:87ba with SMTP id t2-20020a19ad02000000b004f2509b87bamr55370lfc.50.1684443080480; Thu, 18 May 2023 13:51:20 -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: From: Song Liu Date: Thu, 18 May 2023 13:51:08 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/5] mm: intorduce __GFP_UNMAPPED and unmapped_alloc() To: Kent Overstreet Cc: Mike Rapoport , 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-Rspamd-Queue-Id: 87CA74000A X-Rspam-User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weTT F2E2qDUD4A0ENraNGmy2G1DwF3a6OnssMF8EcE6Cf1p/hBA+AihuMStm4Fwdn9KM/GzWMC9WDJ3Elo342bmx2hmOATs9obpxgHWT+z9vz3hcza7FY47i+quPTDvrRPgQ88GanaiD9iHbSmPgPTaNEE34UMsVbvVIhE/aHGpcayLANnwHjtVhPQ0S/NS7cxO3L2OlPrUBAnfjryNHgQbm90tF0kWTXEEefjfAWl4reo9lrwP2KWkc+OwKF3Qs4ebRZRwQYs9aVYrxcXAYZUeAK7R6YdN61MdsDSfQx0o+UnPbIs+tRMeUCzfZ8EW4W3j3Otue0ImUjdDIaDHVmBeyC9ZFfVBkY/hQ+uV2flB3yvzO5OCsL7VkLxd0YUsUHBXR4t1MkuFOobMEFEY9l/rH6mmq/PoEuAzZFox27S292WchF+oEOBD5BKLohGzO5nJLAHZvXTsH81JN5zAM= 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 12:15=E2=80=AFPM Kent Overstreet wrote: > > On Thu, May 18, 2023 at 12:03:03PM -0700, Song Liu wrote: > > On Thu, May 18, 2023 at 11:47=E2=80=AFAM Song Liu wro= te: > > > > > > On Thu, May 18, 2023 at 10:24=E2=80=AFAM Kent Overstreet > > > wrote: > > > > > > > > On Thu, May 18, 2023 at 10:00:39AM -0700, Song Liu wrote: > > > > > On Thu, May 18, 2023 at 9:48=E2=80=AFAM Kent Overstreet > > > > > wrote: > > > > > > > > > > > > On Thu, May 18, 2023 at 09:33:20AM -0700, Song Liu wrote: > > > > > > > I am working on patches based on the discussion in [1]. I am = planning to > > > > > > > send v1 for review in a week or so. > > > > > > > > > > > > Hey Song, I was reviewing that thread too, > > > > > > > > > > > > Are you taking a different approach based on Thomas's feedback?= I think > > > > > > he had some fair points in that thread. > > > > > > > > > > Yes, the API is based on Thomas's suggestion, like 90% from the d= iscussions. > > > > > > > > > > > > > > > > > My own feeling is that the buddy allocator is our tool for allo= cating > > > > > > larger variable sized physically contiguous allocations, so I'd= like to > > > > > > see something based on that - I think we could do a hybrid budd= y/slab > > > > > > allocator approach, like we have for regular memory allocations= . > > > > > > > > > > I am planning to implement the allocator based on this (reuse > > > > > vmap_area logic): > > > > > > > > Ah, you're still doing vmap_area approach. > > > > > > > > Mike's approach looks like it'll be _much_ lighter weight and highe= r > > > > performance, to me. vmalloc is known to be slow compared to the bud= dy > > > > allocator, and with Mike's approach we're only modifying mappings o= nce > > > > per 2 MB chunk. > > > > > > > > I don't see anything in your code for sub-page sized allocations to= o, so > > > > perhaps I should keep going with my slab allocator. > > > > > > The vmap_area approach handles sub-page allocations. In 5/5 of set [2= ], > > > we showed that multiple BPF programs share the same page with some > > > kernel text (_etext). > > > > > > > Could you share your thoughts on your approach vs. Mike's? I'm newe= r to > > > > this area of the code than you two so maybe there's an angle I've m= issed > > > > :) > > > > > > AFAICT, tree based solution (vmap_area) is more efficient than bitmap > > > based solution. > > Tree based requires quite a bit of overhead for the rbtree pointers, and > additional vmap_area structs. > > With a buddy allocator based approach, there's no additional state that > needs to be allocated, since it all fits in struct page. To allocate memory for text, we will allocate 2MiB, make it ROX, and then use it for many small allocations. IIUC, buddy allocator will use unallocat= ed parts of this page for metadata. I guess this may be a problem, as the whole page is ROX now, and we have to use text_poke to write to it. OTOH, if we allocate extra memory for metadata (tree based solution), all the metadata operations can be regular read/write. Thanks, Song