Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2807991lqo; Mon, 20 May 2024 18:56:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVg7NEjX/p6yYQ4f5GNmmGVl+WLBoC3OkA2fYqkcCdVqGZGHZ7i5JCrDWFTfdzVCyfCd7Q4eK2R9Div5cbzDVNHm7B2MziQ7vgOqeO8Og== X-Google-Smtp-Source: AGHT+IGKYc1VhNWk7/mlQt1EY5uMsdsttV60CiE2drRsXZoEGGEdIZDQLoiB2ljAm+aJ4X8icgNq X-Received: by 2002:a05:6a20:914f:b0:1ac:f796:963c with SMTP id adf61e73a8af0-1afde1ddaa9mr37584386637.56.1716256591725; Mon, 20 May 2024 18:56:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716256591; cv=pass; d=google.com; s=arc-20160816; b=garNWQs88Mw+LWH6W5HoKfNz3dOVjBKgVPm3jWGdwkGwHRuwWCZUI3BsN9VwYd6JbU l1Ej3AkMenBkYfvGXFBubmIqWjOZ4filvDNLsZb1pXr7D9VyRleDEw11hKyGpznrW7fA CQJRiPTfWwjdxnzai5yS0HqpFxHcw51/ES5E8D5d5uFqpDzY7P7vQ/FctDKlTVO5Wzlm 1Wmhn97TWdKlVzjYs/K3zGMcNA6bfy54KwN1J0hziCgFBbWHKICogO+aFuXP5xomM0mG Z2V4n/MzI3AAy0uyEjT/i9FMrSUgIK7KSEl0bQPQy7ACsKa1AIBySAhxm+GrfblP8HlQ Z02g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fhJpPLfuGesh5xjpS2ooud1QHAhQN17zzkTpX05wogo=; fh=knonXRTBALaNNlMWgADG4T9+f7LVoZh18JeQIPQ1ocM=; b=AZh/ETKucnbksAfUDIpVauqFMgnPFqJuEr5ESNLLldLeyQvkw28UQAG39AaXYicBVa yDWEBJOvecn6Ta251VxWF1N1gXY6vrKeXVxbbNDxki17g6no1L2yQQ0Qi4Yxii1HNwrM tEHzF+DvQHsiIOgYoZ15IN8mgyhUW/GUoc+KUdleWMnZH5v1+i/R87ys1+g8FdoeBOyM NjjPG0V+Fwz00uzIJGLoefVD7u9K8KqpXL2ibeQ4O/6NP4WWHoOHFYkm9EZfrUVSl6f9 t7TNeVdPSzpLFDDNUIZy06GkoSLKGk0tYi8mp3Z7fdDNSMC0cdSE7ubV6kgYX8/IJdaR 46Rg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=R+Lj7Z7v; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-184323-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184323-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2b671689f82si1154439a91.163.2024.05.20.18.56.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:56:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184323-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=R+Lj7Z7v; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-184323-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184323-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id C6677B21BDD for ; Tue, 21 May 2024 00:40:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7937779F3; Tue, 21 May 2024 00:40:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="R+Lj7Z7v" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (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 8610E8C13 for ; Tue, 21 May 2024 00:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716252033; cv=none; b=pGl1nRQjuANlpVS8FbTXrWuzCiYePUIQTUH6jRg4XabE4JCvJ8zdVCswA4J/Om13vYap40j85VrMCz5dL4veUdD58W9R3DMVBf8NjiWKf2aeIHJJTRdMyiKIkvfOmUyvE9NvHXCJhlmckJVE4HsUXvPEUuky3phVA79gkIf5UqM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716252033; c=relaxed/simple; bh=hMXl4GGJLrT92Xq0c93dhj+xTGmnztuMmWI3Q9ymWNU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WyGmBytAn1r1sRUcnG+Mwo1tG9GhuvI4DP/47YB8BMeIv5fp0D4BgGxBQZL8vIO2M3r7rvc0qwFkrl/G2VrcxU/H0VmQseQVdNqCDlOnl9pzzGI2uEfA8covHCPi5awp4G/yKM7uOvfByZQBw9j6lS9xBschwhCUG5nTMSl4N6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=R+Lj7Z7v; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org 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=fhJpPLfuGesh5xjpS2ooud1QHAhQN17zzkTpX05wogo=; b=R+Lj7Z7v6/FN80b12xRt8G1B6L grttWoFFRn8nll+Zj0fbeGOQ4UpJxel0aNToiDuunEGDZG7KGSC8MdkyBiTmeB648GIBRUHaatq9H Fq1S7lbcKQL4q2zOI+ZwAJ0C8WjfVw0XrH9QTukhaHlPc5Q3Kiep8xKakIzbj0d7g2MFXC/K0vvno 2VRQl7bYA9h4mr40KSKSFixezJ9Rbiu1Pew8y+yTqHLbdlZvwxH1mZOPP3nU/gTW6dia/ASyV9ru2 JgVF8tDPZhETsFexqFumDANwDt6zPYpx1/mj/gH1IjWiR/Y7xoRLS5D9gRPjglYtOxhzeM0gPv2qG 9wmt/kGQ==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1s9DYI-0000000GXPM-3aa3; Tue, 21 May 2024 00:40:26 +0000 Date: Tue, 21 May 2024 01:40:26 +0100 From: Matthew Wilcox To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, vishal.moola@oracle.com, muchun.song@linux.dev, peterx@redhat.com, osalvador@suse.de Subject: Re: [PATCH] mm/hugetlb: remove {Set,Clear}Hpage macros Message-ID: References: <20240520224407.110062-1-sidhartha.kumar@oracle.com> <26e49614-ddb5-4d4c-97c1-a3a8c06d5bb5@oracle.com> 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-Disposition: inline In-Reply-To: <26e49614-ddb5-4d4c-97c1-a3a8c06d5bb5@oracle.com> On Mon, May 20, 2024 at 04:44:53PM -0700, Sidhartha Kumar wrote: > On 5/20/24 4:30 PM, Matthew Wilcox wrote: > > On Mon, May 20, 2024 at 03:44:07PM -0700, Sidhartha Kumar wrote: > > > All users have been converted to use the folio version of these macros, > > > we can safely remove the page based interface. > > > > Yay! > > > > Reviewed-by: Matthew Wilcox (Oracle) > > There is only one remaining user of page-based Test version of these macros. > > in mm/memory-hotplug.c: > > if (!PageHuge(page)) > continue; > head = compound_head(page); > /* > * This test is racy as we hold no reference or lock. The > * hugetlb page could have been free'ed and head is no longer > * a hugetlb page before the following check. In such unlikely > * cases false positives and negatives are possible. Calling > * code must deal with these scenarios. > */ > if (HPageMigratable(head)) > goto found; > skip = compound_nr(head) - (pfn - page_to_pfn(head)); > > > I've previously sent a patch to convert this to folios[1] but got feedback > that it was unsafe. But I'm not sure why replacing compound_head() with > page_folio() and using folio_test_hugetlb_migratable(folio) rather than > HPageMigratable(head) changes the existing behavior. With no reference or > lock, can't the head pointer also be moved and no longer be a part of page > like the comment states. So would the folio conversion just be maintaining > this level of existing un-safety that the calling code should handle > anyways? To be fair, that wasn't the last thing I said about that ... https://lore.kernel.org/lkml/Y89DK23hYiLtgGNk@casper.infradead.org/ and looked like David agreed that this was a case where false postive/negative was fine; we were just looking to be right most of the time.