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 X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7F0BC433EF for ; Thu, 23 Sep 2021 03:45:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 72AB560F4C for ; Thu, 23 Sep 2021 03:45:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 72AB560F4C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id EB222900002; Wed, 22 Sep 2021 23:45:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E39EA6B0071; Wed, 22 Sep 2021 23:45:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDAA2900002; Wed, 22 Sep 2021 23:45:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0051.hostedemail.com [216.40.44.51]) by kanga.kvack.org (Postfix) with ESMTP id B9B0D6B006C for ; Wed, 22 Sep 2021 23:45:18 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 68E6418259C47 for ; Thu, 23 Sep 2021 03:45:18 +0000 (UTC) X-FDA: 78617447916.13.1EFA2CA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf03.hostedemail.com (Postfix) with ESMTP id 2694C30000A4 for ; Thu, 23 Sep 2021 03:45:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uMQ0LJdHQ7c4mM7EvTfGeqm/dVXZIGiACxHLT/lLI6Q=; b=ZGZo+ugLQ00vO0vKoAz2R2/AME S2UZfjgIGzzR0DXMWh0A/CidIkYS9+Tf4dXHDIwKxQ8MRqDQ5OxYKyWK95649aU6pWGQ4OmL3iVMz DoE/m/hZabJ1hKOtNq3yhOP6JER0+oEXFoW8DnxzDmvGaJPt7YChrBriNPh3BT9fl5O2bpUFKFlYt 0XgHT1lNsIacNqqchiGtK7gftdB/3qeAUS388tft8r9uKSKcFhilp3kxgTBMsLhvt+FLPP2lp3KKX tKzdkNUahrdF1FCd7t8ZMHMM/A2nZGM7AyZvHXbf0pqCVFs86oa+srwEDCD+5CRWqQ/yWvFKo8uU8 njGbmxWw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTFbc-005UTs-SG; Thu, 23 Sep 2021 03:41:24 +0000 Date: Thu, 23 Sep 2021 04:41:04 +0100 From: Matthew Wilcox To: Ira Weiny Cc: Kent Overstreet , Johannes Weiner , Linus Torvalds , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andrew Morton , "Darrick J. Wong" , Christoph Hellwig , David Howells Subject: Re: Folio discussion recap Message-ID: References: <20210923004515.GD3053272@iweiny-DESK2.sc.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210923004515.GD3053272@iweiny-DESK2.sc.intel.com> X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2694C30000A4 X-Stat-Signature: nxdjz3eyhsmtxxr56d6gu7pbqcswqdzf Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=ZGZo+ugL; spf=none (imf03.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-HE-Tag: 1632368718-402731 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 Wed, Sep 22, 2021 at 05:45:15PM -0700, Ira Weiny wrote: > On Tue, Sep 21, 2021 at 11:18:52PM +0100, Matthew Wilcox wrote: > > +/** > > + * page_slab - Converts from page to slab. > > + * @p: The page. > > + * > > + * This function cannot be called on a NULL pointer. It can be called > > + * on a non-slab page; the caller should check is_slab() to be sure > > + * that the slab really is a slab. > > + * > > + * Return: The slab which contains this page. > > + */ > > +#define page_slab(p) (_Generic((p), \ > > + const struct page *: (const struct slab *)_compound_head(p), \ > > + struct page *: (struct slab *)_compound_head(p))) > > + > > +static inline bool is_slab(struct slab *slab) > > +{ > > + return test_bit(PG_slab, &slab->flags); > > +} > > + > > I'm sorry, I don't have a dog in this fight and conceptually I think folios are > a good idea... > > But for this work, having a call which returns if a 'struct slab' really is a > 'struct slab' seems odd and well, IMHO, wrong. Why can't page_slab() return > NULL if there is no slab containing that page? No, this is a good question. The way slub works right now is that if you ask for a "large" allocation, it does: flags |= __GFP_COMP; page = alloc_pages_node(node, flags, order); and returns page_address(page) (eventually; the code is more complex) So when you call kfree(), it uses the PageSlab flag to determine if the allocation was "large" or not: page = virt_to_head_page(x); if (unlikely(!PageSlab(page))) { free_nonslab_page(page, object); return; } slab_free(page->slab_cache, page, object, NULL, 1, _RET_IP_); Now, you could say that this is a bad way to handle things, and every allocation from slab should have PageSlab set, and it should use one of the many other bits in page->flags to indicate whether it's a large allocation or not. I may have feelings in that direction myself. But I don't think I should be changing that in this patch. Maybe calling this function is_slab() is the confusing thing. Perhaps it should be called SlabIsLargeAllocation(). Not sure.