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 28DF2C54E71 for ; Fri, 22 Mar 2024 12:43:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65F2A6B0087; Fri, 22 Mar 2024 08:43:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5E8326B0089; Fri, 22 Mar 2024 08:43:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B1A36B008A; Fri, 22 Mar 2024 08:43:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 358B36B0087 for ; Fri, 22 Mar 2024 08:43:14 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 8FBF7A09E9 for ; Fri, 22 Mar 2024 12:43:13 +0000 (UTC) X-FDA: 81924640266.30.59B126E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf21.hostedemail.com (Postfix) with ESMTP id 3E9931C0005 for ; Fri, 22 Mar 2024 12:43:10 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=H2KgWLTj; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711111392; a=rsa-sha256; cv=none; b=yCIXT2dGJri4ZItFh0RuBKZuUluq9g5Bzz1l2cH2lW8xsqczgSlKL2LI/jMgXg2KMO2ElG xW4jiIJCf5K/0EymesVx9ccWfo5cePsmLbtWsYblWGRqYgZdphyMsEhZEsN/u4bRJzq/3X Z77hkDSV5wQW6nG7JfptPKCxXl706DQ= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=H2KgWLTj; dmarc=none; spf=none (imf21.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711111392; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=04YOHaBRhbqoOxOIZ7hdPZMfiximkVU4bwx6qfW4FIw=; b=jcu1VB6gKWG8/jprhMN5vgujh3GfIiyPceMS1duG8pJe6R1YyEPDl70NEQdD1E8oH7JPLd B8H8zj3EN7f52dfF15Z0HFTGtbHYIdOUweYgtXsF7VKnd3WF6c33qaD7hgFuby8PEGlToQ BTMQPLW8TmX5F8Hi3pkmpUqzozPn3gY= 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=04YOHaBRhbqoOxOIZ7hdPZMfiximkVU4bwx6qfW4FIw=; b=H2KgWLTjb1dJoCTdtJD1mBmIuV /b27d0e5JqidyrSL8ucTHBK86pReETba1HetMszs2ACxnXHbDR8bFyE31N2Wwm9L1Zta2E8RE/oLQ etq1nnx8qUyO78hg/A7TUIxIEHBZNRBibdVuKui8vD1mXPCHQd8wBprxmD1sbiW3HYvxJV+eFf1P1 sXZwF8dyH7N0fGCOh2UA3Gul29i9XgL2yoLem5T/ZsxNp9wkggaWMtfInV1yi+v+E92k4WRe0NDwA CQh+VHfqlOTeeRZ9LgzESINTXoIkcPayW6trwJ77j56GmNx0eC/5UmGXJ9Zg+QkzgPKeAgC5DRtMa 8FYnVvsA==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rneEk-00000009IMu-2cth; Fri, 22 Mar 2024 12:43:06 +0000 Date: Fri, 22 Mar 2024 12:43:06 +0000 From: Matthew Wilcox To: Vlastimil Babka Cc: Andrew Morton , linux-mm@kvack.org, David Hildenbrand , Miaohe Lin , Muchun Song , Oscar Salvador Subject: Re: [PATCH 4/9] mm: Support page_mapcount() on page_has_type() pages Message-ID: References: <20240321142448.1645400-1-willy@infradead.org> <20240321142448.1645400-5-willy@infradead.org> <507dc279-fc1e-478c-a4af-7181a3593171@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <507dc279-fc1e-478c-a4af-7181a3593171@suse.cz> X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3E9931C0005 X-Stat-Signature: 1w7fg3acb9xjhmogznz6ecs49bbkaoew X-HE-Tag: 1711111390-204151 X-HE-Meta: U2FsdGVkX1+wQFwipUasbluT/+FX5fP6dsoLAwtsnjbOlFqCNZtqaJQETMz1ZKS6s0DJHiUanVrK55x28Uv8mBfxvgBY/zpbi4m2KhgAqIUTJ/V5TJGOfsNahGPnBhOA79/jRk/wC8wJl4UUWDjwOraN9Tlr/n3BXKX0rjqK0goMl85WqJcDp/I6XmYL9hfGrsU6QNiG+a1g8CN7uTKvn9+E220/Hk0V5twyn/QU8q8wgs6Is/QBcz04hSyBzPH+VuVD2TkgmDkgDJsfP9bZ7gDYWSshhj7eoihX8Dqtx0QJwVVdA6oAkG3N4XXVyPtk+CFKrqy/XPpR2tgOWCkSBpTLxuWCakL0kBc7z7rNUvr0FiY4j1zgVkc9je9bHUV/PEWmtNw44czLhNiDJ7XGSig09bnEy2tLBYWWbRb0fcmMFaxJeNkP/poAdD1MtwqGy7aJQphmkYA9sqJiyjP9BGd1H+H/h6nxGnmBTHgv4Rtcox8e9pGDEO4+jIXAMHevACBPWJMbUPBc8UW34O7hKOOKERMXP/k0aGChOFZHt1QtofUt23DUES8lj9CuZKqCdofEDN3ej0BQtXtjDT6RqfgRIbOtP6vULaMYBZSb31zsiST4cKDmDF3okzeJTfrUxYyPzmcCA+s02AArbCt7EwhUGvlvPQDYn7z6dYOF17TFo+34ZQC6HruwdOq6ZrRWAfC8cnvG8DaOLeOgwY2bB6G2s/xjLwRZ2vnC22PJhJuTJEX6+oASsqyC7J9mUm0dzgZLDGp7NWbnKN8rxgSAwkuqKiL4Fv+r+VLH4Yw1NyC9kRPylFTK/smt2b7IMsJdddc4wdj8FCAf944bOezysNDrJA5kHKzRHXaLQ9awHM0tgFQsP3bJD8e9o0WXdxXhHo4xVvqbjZYUIPs6RGJoo5HxumIXy9fvHWk3jvIJnhymJKej+VhWBjlDZ2oO7zaBM1852KAZqRrCUR27n/7 6rmsQw1A OhpuBVV4WSdXoBTr4juk9R0jdFN/33dZ6KX2vazj7chYllJCDrUccp3/mVPxZfz+okQO5rhkxfpYB49aNyPCFVX7R715elajmzedCOZV55S5Y7TaAFIfU7g2sty9QnBkNh5A9bJZyufnuPyJtaiaFXTL4rI3xn/TWch1peOecd+GyNe2SfVx0xZvq32znYPTNKH5m0uQ59mnYyu/aox6Yda472UB45yKKGiDMvdVevkymsL2EjAsUy9dOcA== 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: List-Subscribe: List-Unsubscribe: On Fri, Mar 22, 2024 at 10:43:38AM +0100, Vlastimil Babka wrote: > On 3/21/24 15:24, Matthew Wilcox (Oracle) wrote: > > Return 0 for pages which can't be mapped. This matches how page_mapped() > > works. It is more convenient for users to not have to filter out > > these pages. > > > > Signed-off-by: Matthew Wilcox (Oracle) > > Hm strictly speaking you shouldn't be removing those PageSlab tests until > it's changed to a PageType in 7/9? If we're paranoid enough about not > breaking bisection between this and that patch. I thought about that. Slub currently doesn't use the field while will become __page_type, so it's left set to -1 by the page allocator. So this is safe. Thanks for checking that though ;-) > Otherwise > > Acked-by: Vlastimil Babka > > > --- > > fs/proc/page.c | 7 ++----- > > include/linux/mm.h | 8 +++++--- > > include/linux/page-flags.h | 4 ++-- > > 3 files changed, 9 insertions(+), 10 deletions(-) > > > > diff --git a/fs/proc/page.c b/fs/proc/page.c > > index 195b077c0fac..9223856c934b 100644 > > --- a/fs/proc/page.c > > +++ b/fs/proc/page.c > > @@ -67,7 +67,7 @@ static ssize_t kpagecount_read(struct file *file, char __user *buf, > > */ > > ppage = pfn_to_online_page(pfn); > > > > - if (!ppage || PageSlab(ppage) || page_has_type(ppage)) > > + if (!ppage) > > pcount = 0; > > else > > pcount = page_mapcount(ppage); > > @@ -124,11 +124,8 @@ u64 stable_page_flags(struct page *page) > > > > /* > > * pseudo flags for the well known (anonymous) memory mapped pages > > - * > > - * Note that page->_mapcount is overloaded in SLAB, so the > > - * simple test in page_mapped() is not enough. > > */ > > - if (!PageSlab(page) && page_mapped(page)) > > + if (page_mapped(page)) > > u |= 1 << KPF_MMAP; > > if (PageAnon(page)) > > u |= 1 << KPF_ANON; > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index 0436b919f1c7..5ff3d687bc6c 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1223,14 +1223,16 @@ static inline void page_mapcount_reset(struct page *page) > > * a large folio, it includes the number of times this page is mapped > > * as part of that folio. > > * > > - * The result is undefined for pages which cannot be mapped into userspace. > > - * For example SLAB or special types of pages. See function page_has_type(). > > - * They use this field in struct page differently. > > + * Will report 0 for pages which cannot be mapped into userspace, eg > > + * slab, page tables and similar. > > */ > > static inline int page_mapcount(struct page *page) > > { > > int mapcount = atomic_read(&page->_mapcount) + 1; > > > > + /* Handle page_has_type() pages */ > > + if (mapcount < 0) > > + mapcount = 0; > > if (unlikely(PageCompound(page))) > > mapcount += folio_entire_mapcount(page_folio(page)); > > > > diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h > > index 8d0e6ce25ca2..5852f967c640 100644 > > --- a/include/linux/page-flags.h > > +++ b/include/linux/page-flags.h > > @@ -971,12 +971,12 @@ static inline bool is_page_hwpoison(struct page *page) > > * page_type may be used. Because it is initialised to -1, we invert the > > * sense of the bit, so __SetPageFoo *clears* the bit used for PageFoo, and > > * __ClearPageFoo *sets* the bit used for PageFoo. We reserve a few high and > > - * low bits so that an underflow or overflow of page_mapcount() won't be > > + * low bits so that an underflow or overflow of _mapcount won't be > > * mistaken for a page type value. > > */ > > > > #define PAGE_TYPE_BASE 0xf0000000 > > -/* Reserve 0x0000007f to catch underflows of page_mapcount */ > > +/* Reserve 0x0000007f to catch underflows of _mapcount */ > > #define PAGE_MAPCOUNT_RESERVE -128 > > #define PG_buddy 0x00000080 > > #define PG_offline 0x00000100 >