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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3AD40C433F5 for ; Mon, 27 Sep 2021 18:33:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D91C160FBF for ; Mon, 27 Sep 2021 18:33:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D91C160FBF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=shutemov.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 56CED900002; Mon, 27 Sep 2021 14:33:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 51B866B0071; Mon, 27 Sep 2021 14:33:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 40A9C900002; Mon, 27 Sep 2021 14:33:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0185.hostedemail.com [216.40.44.185]) by kanga.kvack.org (Postfix) with ESMTP id 31C686B006C for ; Mon, 27 Sep 2021 14:33:54 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DCA45348D0 for ; Mon, 27 Sep 2021 18:33:53 +0000 (UTC) X-FDA: 78634202346.08.D06C73F Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) by imf04.hostedemail.com (Postfix) with ESMTP id 83E9650000B7 for ; Mon, 27 Sep 2021 18:33:53 +0000 (UTC) Received: by mail-lf1-f43.google.com with SMTP id b20so81773140lfv.3 for ; Mon, 27 Sep 2021 11:33:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shutemov-name.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=OkJDRTajjBYXZ9Lg7Znrw7BKNW4OCn6XI+sAVpYq6QI=; b=qdXZo0VKKvGxILef7JmwcenBcQKasiE54pz+WtZ2c1nuNKo0FWwkU4SAgC8IVJn75f mjCpRzf2uF1ul1E1lLRt6og0U0UE8lupicpoy8MsJhx87RW7ZRF2/IiAQk3X1EUkad/H SVS+td1Hcckzl3bVIQ07SGPH73T8NApdeMk8LCcoF2OmE1LvJCngQws8nZxjbVLviqFi MxSH0Z+tnuLGIuvHGzZCKU2j4H7he35g2cRq+JBRytRejIalREMLXhS8wizSW8YBtCx5 yBzTEMlPIXVM4MsxAAcqg2DzUqMznWk6dIwbo5IJOFQPk0OMFQy66/jsTIEPNfLt13Kq kzEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=OkJDRTajjBYXZ9Lg7Znrw7BKNW4OCn6XI+sAVpYq6QI=; b=IEWlkAhlbbDrXenNrB/56cbXC2RCalGSjwszN5//CY8TdTsmAAFmnaW23ckGrkFvfn P//DrWVW1JsDhVFpreepeM+XGXi90jDCMvfeJyTp4U8jjHX8khfcCCLb84AfIM2osTyG etILQ8p1bVNpXhv7IHmUP5v0tzCqQsy+Hp8ur/WZX+hRzNhHMti63gxF45tszzmOH4El ANLVwzqwdAbe9JrslWYzehjGDlfdKI9p6GlYWb4xlCUpdfIFwJQWyIDNG/lZzk4RPvRN 3ooNRszeZPn4xFnfCjhz2q6oLcnqKF5nye7aRdZHW06+iyMKOn57J3QA7kNaLo+wzBkM VbgQ== X-Gm-Message-State: AOAM532CC5ktrDDai2eSsyCd6BUGDOSCglUSc69C+h6nq2uNJhMZhs4J 6U3q5H2I37eP3vBXSAWNCMcYUA== X-Google-Smtp-Source: ABdhPJzWZh6daO8VsDoVks7ChKfKV/MwaTxKX73LmO60ysmNU0X0sNpEippMfCo/ilGu6AoJUJdENA== X-Received: by 2002:ac2:561c:: with SMTP id v28mr1153727lfd.457.1632767631753; Mon, 27 Sep 2021 11:33:51 -0700 (PDT) Received: from box.localdomain ([86.57.175.117]) by smtp.gmail.com with ESMTPSA id n9sm1672309lfu.88.2021.09.27.11.33.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Sep 2021 11:33:51 -0700 (PDT) Received: by box.localdomain (Postfix, from userid 1000) id E89C5102FE0; Mon, 27 Sep 2021 21:33:50 +0300 (+03) Date: Mon, 27 Sep 2021 21:33:50 +0300 From: "Kirill A. Shutemov" To: Matthew Wilcox Cc: Vlastimil Babka , Kent Overstreet , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Johannes Weiner , Linus Torvalds , Andrew Morton , "Darrick J. Wong" , Christoph Hellwig , David Howells Subject: Re: Struct page proposal Message-ID: <20210927183350.obd756wnsctukf63@box.shutemov.name> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=shutemov-name.20210112.gappssmtp.com header.s=20210112 header.b=qdXZo0VK; spf=none (imf04.hostedemail.com: domain of kirill@shutemov.name has no SPF policy when checking 209.85.167.43) smtp.mailfrom=kirill@shutemov.name; dmarc=none X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 83E9650000B7 X-Stat-Signature: xha7frn8pa93ttzwf4a8q3k7zq6hjg9f X-HE-Tag: 1632767633-234985 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 Mon, Sep 27, 2021 at 07:05:26PM +0100, Matthew Wilcox wrote: > On Mon, Sep 27, 2021 at 07:48:15PM +0200, Vlastimil Babka wrote: > > On 9/23/21 03:21, Kent Overstreet wrote: > > > So if we have this: > > > > > > struct page { > > > unsigned long allocator; > > > unsigned long allocatee; > > > }; > > > > > > The allocator field would be used for either a pointer to slab/slub's state, if > > > it's a slab page, or if it's a buddy allocator page it'd encode the order of the > > > allocation - like compound order today, and probably whether or not the > > > (compound group of) pages is free. > > > > The "free page in buddy allocator" case will be interesting to implement. > > What the buddy allocator uses today is: > > > > - PageBuddy - determine if page is free; a page_type (part of mapcount > > field) today, could be a bit in "allocator" field that would have to be 0 in > > all other "page is allocated" contexts. > > - nid/zid - to prevent merging accross node/zone boundaries, now part of > > page flags > > - buddy order > > - a list_head (reusing the "lru") to hold the struct page on the appropriate > > free list, which has to be double-linked so page can be taken from the > > middle of the list instantly > > > > Won't be easy to cram all that into two unsigned long's, or even a single > > one. We should avoid storing anything in the free page itself. Allocating > > some external structures to track free pages is going to have funny > > bootstrap problems. Probably a major redesign would be needed... > > Wait, why do we want to avoid using the memory that we're allocating? Intel TDX and AMD-SEV have concept of unaccpeted memory. You cannot use the memory until it got "accepted". The acceptance is costly and I made a patchset[1] to pospone the accaptance until the first allocation. So pages are on free list, but page type indicate that it has to go though additional step on allocation. [1] https://lore.kernel.org/all/20210810062626.1012-1-kirill.shutemov@linux.intel.com/ -- Kirill A. Shutemov