From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 419681BF2B; Thu, 4 Apr 2024 20:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712262699; cv=none; b=s8nUYNUiwN2PIyrn+s2gkHtsE1kC9YygL/rCzigYMJFWoS6HgE3GcjesFl7shtyvr3FHawcHJuXulcnGHwpf6/m2VrlUmuP0VyGM8odXwaAUC8H5DlebS69rDFxcILjv14iR02dQmj/0PU8EUERslE+jUNIKuakKEM41b/6NGtQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712262699; c=relaxed/simple; bh=Hew0RwkTVS+l0xV7qv/+83XciUA+bvPNzdeJES2OSX0=; h=Date:From:To:Cc:Subject:Message-Id:In-Reply-To:References: Mime-Version:Content-Type; b=ZBbnguVXMOLbVs4BROYQAGehj0BlHgA7eUwxjjYL4GGr/19XOW8sWg9rQuFJpoPC0y14oZ9FLCFQBzTBRHfo0j0Ja5E27wFiS+tXvdMTUFUEaWtOvkVa8NJKJhfFr6D21TRQPpReCValfe1RAQDfnPS+acw2hr73CkEOkfuwuGs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=NTlQyc15; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="NTlQyc15" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41B6DC433F1; Thu, 4 Apr 2024 20:31:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1712262698; bh=Hew0RwkTVS+l0xV7qv/+83XciUA+bvPNzdeJES2OSX0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=NTlQyc15FdIpH8wOQyWjdMc8ZAOzRRTs+StY6AGUQ8aSgIpT7U6MEU0T/fmuyZviy K3fDvwFoqOb7TYdlZjCXLuzfOk9ivwYIWgn9HI2LADsG4HN4as9HbEaPxVkJuNrOZZ fVFPdzrzbWjMzZ01wXPrfGGLtOHoybr3B9Q1Vl68= Date: Thu, 4 Apr 2024 13:31:37 -0700 From: Andrew Morton To: Peter Xu Cc: Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Huacai Chen , David Hildenbrand , Jason Gunthorpe , Nathan Chancellor , WANG Xuerui , Ryan Roberts , loongarch@lists.linux.dev Subject: Re: [PATCH 1/3] mm: Allow anon exclusive check over hugetlb tail pages Message-Id: <20240404133137.560d15c1a3bc7176424901fb@linux-foundation.org> In-Reply-To: References: <20240403013249.1418299-1-peterx@redhat.com> <20240403013249.1418299-2-peterx@redhat.com> X-Mailer: Sylpheed 3.8.0beta1 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 4 Apr 2024 10:21:21 -0400 Peter Xu wrote: > Andrew, could you help update with Matthew's fixup? The comment is > definitely better than what I wrote in all cases. From: Andrew Morton Subject: mm-allow-anon-exclusive-check-over-hugetlb-tail-pages-fix Date: Thu Apr 4 01:27:47 PM PDT 2024 simplify PageAnonExclusive(), per Matthew Link: https://lkml.kernel.org/r/Zg3u5Sh9EbbYPhaI@casper.infradead.org Cc: David Hildenbrand Cc: Huacai Chen Cc: Jason Gunthorpe Cc: Matthew Wilcox (Oracle) Cc: Nathan Chancellor Cc: Peter Xu Cc: Ryan Roberts Cc: WANG Xuerui Signed-off-by: Andrew Morton --- include/linux/page-flags.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/include/linux/page-flags.h~mm-allow-anon-exclusive-check-over-hugetlb-tail-pages-fix +++ a/include/linux/page-flags.h @@ -1096,11 +1096,10 @@ static __always_inline int PageAnonExclu { VM_BUG_ON_PGFLAGS(!PageAnon(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. + * HugeTLB stores this information on the head page; THP keeps it per + * page */ - if (PageHuge(page) && !PageHead(page)) + if (PageHuge(page)) page = compound_head(page); return test_bit(PG_anon_exclusive, &PF_ANY(page, 1)->flags); } _