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 CF072CD1284 for ; Thu, 4 Apr 2024 13:46:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6770D6B0087; Thu, 4 Apr 2024 09:46:07 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6266B6B0088; Thu, 4 Apr 2024 09:46:07 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4ED916B0089; Thu, 4 Apr 2024 09:46:07 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3023A6B0087 for ; Thu, 4 Apr 2024 09:46:07 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E1FDE1C0F87 for ; Thu, 4 Apr 2024 13:46:06 +0000 (UTC) X-FDA: 81971973132.03.EA7F457 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id E376E2001E for ; Thu, 4 Apr 2024 13:46:04 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekfguBny; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712238365; 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=EmzOZMLQMmyXptbwJ4TCleo+H/I/LAr89e90GsrIjic=; b=GSfpRwRo5d2B6DMK5mC9X9Y3L6N6SnrUOO7osUn77EBzZMGSDoAzPjS9ZUgqO7xRevbK16 UkS9nHQLu2pikcYAzUuRky5XUQ7RSWlfF01V99ntYeQHj0cqTDJHW3I/fD9Xkw+dRmwSfK QsGZNHn2AcuazT4HUNo+Hkf6GhyX9cs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712238365; a=rsa-sha256; cv=none; b=IGH3/2QHuKpvsOXO6PXgUa3mAQntzstjXFjBob/t5gQDTC37EN7aFK91k2lLrMypMNXNmj ZXhsDPdwdvUN9O9iWV41z6P7yh4i+7P1l/16Ucdiy1DgCT9uFw0dCBcqxbHnAZSMvLWe8U SBqHkN7/L1o0TTzkgwtbJvJA4VaWXAU= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ekfguBny; spf=pass (imf13.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1712238364; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=EmzOZMLQMmyXptbwJ4TCleo+H/I/LAr89e90GsrIjic=; b=ekfguBnycU5JvUlHfHc7OWdJld8xq9mb9XvIwEiqYXBFjQhlJAvD5QFg6qndYYh8q2St3I 7OY0SVEJRLuvUWh9zW3dkP4MAuonFKE7teMySR+nBpY2bv5pxgIaU6GbkHlqjyW1lXHMr1 rF6f9GdvdUys+/lCDL6dYLyLKFZGKls= Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-390-tz1gKshgPKC-JughhnVZVA-1; Thu, 04 Apr 2024 09:46:02 -0400 X-MC-Unique: tz1gKshgPKC-JughhnVZVA-1 Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-78d438954abso10225085a.1 for ; Thu, 04 Apr 2024 06:46:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712238362; x=1712843162; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=EmzOZMLQMmyXptbwJ4TCleo+H/I/LAr89e90GsrIjic=; b=r7xgyP8JGDkQzZ7pj22r0L90JWNjVn0hovl9ljIZ+XiTQcR6JrdXAX6MoZhOqIYHVT c2P2Ela8DnvscATESvpZvnij3C6q5nEEPEBQKRcIIg76Hke2u5cFM/N/8CLV+pEoVLC6 ZzD2v/vU660wxGv4DB6N/KlYAYTio4VjtYvbTSfuzHak5jWHQisFmHFEeKlFCuMHkWlP SsH5O0gbn43kjOY7pSMF/tNZQ7EHinaNdnhdhLGMsopmSLYR3G8SLN/ebwH7G/M6w2nq dfV0M+1IPoT5mjktwFSJ5iENbkuNQuFe+A/aJaaQ4cm31zI+yhxHA3mU+q/KgVoitQfV leWg== X-Gm-Message-State: AOJu0Yx/romIC0OoT9o2xOGXEabh96Kf8qaESQaeLSlCGUsTfVCN7+3x 7g+XUZInnaGLE9uWFfm7ABakgQc2kQkGjmrxXSBoGtVbXGM94tnH18M+Ig4/V1j7LguPUH+Prp1 cT/2ga6dNmptHoqU/Cwhp63+OP0iayZxj3Aeta7KhFV96eOdR X-Received: by 2002:a05:6214:5084:b0:699:2f16:4d2d with SMTP id kk4-20020a056214508400b006992f164d2dmr2447156qvb.3.1712238361988; Thu, 04 Apr 2024 06:46:01 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGJdNkFmzOBKBFyhb53lG1h+VUGQqqfUd/DRv4waZks+wqY9XKFnnPlb39Aj880wVEqUvqQog== X-Received: by 2002:a05:6214:5084:b0:699:2f16:4d2d with SMTP id kk4-20020a056214508400b006992f164d2dmr2447114qvb.3.1712238361317; Thu, 04 Apr 2024 06:46:01 -0700 (PDT) Received: from x1n ([99.254.121.117]) by smtp.gmail.com with ESMTPSA id g12-20020a0562141ccc00b0069915b47bf4sm2696616qvd.146.2024.04.04.06.46.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 06:46:01 -0700 (PDT) Date: Thu, 4 Apr 2024 09:45:58 -0400 From: Peter Xu To: Matthew Wilcox Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huacai Chen , David Hildenbrand , Jason Gunthorpe , Nathan Chancellor , Andrew Morton , WANG Xuerui , Ryan Roberts , loongarch@lists.linux.dev Subject: Re: [PATCH 1/3] mm: Allow anon exclusive check over hugetlb tail pages Message-ID: References: <20240403013249.1418299-1-peterx@redhat.com> <20240403013249.1418299-2-peterx@redhat.com> MIME-Version: 1.0 In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspamd-Queue-Id: E376E2001E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: dgdqt8fys81x31qdd7m6cojafsbmht7z X-HE-Tag: 1712238364-369955 X-HE-Meta: U2FsdGVkX1+QmRXG5jB0aztvvRSJBGkIUy8CILGNxpxOoiHiSjO7iLG6pc8r7mMHgDQl4KgQuoIxqu4/j8pbm+M0u54cb72NsHnW8Dqn8PXxk4uLwYehsbka227YL6wGNRsmN/IJjO4rztIaaEdkBhGJkCOoBdL/vAl0zIp3ZTR5u+BYfTzTPbvQMBcdkA1DHHcF6Nih2AhR/VqcyG5x/vNSXpSx19IEJKD89Ad+/+z5qGBzYS9w8M8/JlLq4z/7rLtR2FMbDeFXIWTGlgGMoQ3UuYMiw5mSRicDZVipO0dykrrCP+L2subMqKoJ1McC/8RpmbI7RoT4Xnars0IOEAZ23FOSObXilYNAEsXl5Xpue3RThygEB0y3z48ztfEjdjKdFga4w1ZxiJNzjCiWXVpBQJCoIEKFhHOs7kKkiNJYkRIyHsFGbIREn3F9U3AhitOCvCHpP4jgiVnPCzKzF5TENZ4sVXMojI1lofCrNcJCgYGTBEMjGttA402Gy2WghwLAdGbslyIowWJDuDCQAUj3ZXBBnJuos9dREa53ONSrEske+FoW/VXXYGz/Y99jSIiLo/x42122EVrq0EpXnoSwO6djkndWK/JjIhx9Bs1Um83WyiKRz0V7U4R58izLo3hEZ+HfPOdH5Xw4in9WvFl/DfO0Tz/pw2X18B8p6KkFpzkmEfG8HFAGjTy+X4DnAmrhHIla8sANwOvqdLdg50xFR6iVP/6/d0R5joo0g4fIqLxkb0ooy0bydq6PQD+0Wwu0guKI8o5Z51g10koUr+OPYP0bS0Lenl7WKNKarnIMyqC6JT1cQ0C82yJcOXI4cmoxZzZ/5EQEWigFaFYgUV4PYvWsev2OLl66PwXBqglphZrA5DOafvWct7D8p/iInbTQx8G6XtZCJBVaAcQFVppGRT7IfIG4CIHu2/ECirpBMN289T5fwtMYCCr7qXiBQ1nL8cSEv9rWXAEuXf7 /JQvsU9L 48Fo2yhnUOu5wXNtwc9E/f3O/6K9H1C/KeK0AsNmSTsdB3eyjI1WKSJn26whzPKZ8MuH1hJN8rrCi6GpSiwHPMNDHWQ== 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 Thu, Apr 04, 2024 at 01:05:57AM +0100, Matthew Wilcox wrote: > On Tue, Apr 02, 2024 at 09:32:47PM -0400, peterx@redhat.com wrote: > > +++ b/include/linux/page-flags.h > > @@ -1095,7 +1095,13 @@ PAGEFLAG(Isolated, isolated, PF_ANY); > > static __always_inline int PageAnonExclusive(const struct page *page) > > { > > VM_BUG_ON_PGFLAGS(!PageAnon(page), page); > > - VM_BUG_ON_PGFLAGS(PageHuge(page) && !PageHead(page), page); > > + /* > > + * Allow the anon-exclusive check to work on hugetlb tail pages. > > + * Here hugetlb pages will always guarantee the anon-exclusiveness > > + * of the head page represents the tail pages. > > + */ > > + if (PageHuge(page) && !PageHead(page)) > > + page = compound_head(page); > > I think this should be written as: > > /* > * HugeTLB stores this information on the head page; THP keeps > * it per page > */ This comment does look clean and cleaner indeed. And yes, mention THP can be helpful too. > if (PageHuge(page)) > page = compound_head(page); I would think PageHead() check would help us to avoid compound_head() on heads, which should still be the majority cases iiuc (assuming page->flags is already around in the cache anyway). I've no strong opinion though, as I can hardly tell a difference in reality. > > > return test_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); > > } > Thanks, -- Peter Xu