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 87C3017BA6 for ; Fri, 28 Nov 2025 11:26:46 +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=1764329206; cv=none; b=YhMYi1muyuCB+1An4F19bbnRCpaY4EsmKfEll1HCvfF/39LCjMGzpcEaYqd+sRnmE4PCBOYq/+wb6j3BQJ1JdFTCCGi3rfZWmd7BPqHQtizRzFDM0KRnDr0no6j7fFtyrOpaF6vPK0X/uomZo4whdTZg0ZvZUoZuCR/80zdXBaM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764329206; c=relaxed/simple; bh=pixOixLW18MiI7w2OhyFVjtVTI0QWrgN96lX5JcVnGI=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=sFB8VV/W56rCmCdkzLtoXVPqjV0mL2IUJnZWCY69F4fUZOj4OXPEphk1pMIUHDac3YR4BAn02Cf7F7B2Xg6XjVQz1kSHDkLSmaEX2tFGbKJIqJMIKkkMcLo+SsonGxTXp3FVO9XUoejBG5smHZL9nKlpXldWlM0fsK6pLe5FYiI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Ce+yZbIh; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ce+yZbIh" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F14AC4CEF1; Fri, 28 Nov 2025 11:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1764329206; bh=pixOixLW18MiI7w2OhyFVjtVTI0QWrgN96lX5JcVnGI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=Ce+yZbIhiq2cMKfLdkoXgLsyrCnReqnjN4Z0QFeNfmGjycBuAVXpzBoTCbIyEvUN7 TullcC/YkKK0Q/YQoAEK5obFvYdwQERmJD+Uwx4F7NtpNKWGjEUCKUc79VEYJi2Kav 4SfQO/lg0uo9LhA7grPmaT5JqsNum01LVNi/KScFCXMCb0bZSVtDeHFoyxvAlrZWrr uWVxT9XgVqOIzess0ZkuSknSIOzhN/H88f7JW9ZOKNoMOkDY2m9UdO6GCBVEPpKbxF q2XjQcTIewbHDYYuokViM7UbOIKPSwzan4OchotebltAV0O7qzCsodeuqUDPLhzWv4 uLFQ6rezfj3ng== Message-ID: Date: Fri, 28 Nov 2025 12:26:42 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] hugetlb: Add guard support To: Fushuai Wang Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, muchun.song@linux.dev, osalvador@suse.de, wangfushuai@baidu.com References: <9cb0a602-69ca-400f-890c-e9dd5b44f53b@kernel.org> <20251128112307.80237-1-fushuai.wang@linux.dev> From: "David Hildenbrand (Red Hat)" Content-Language: en-US In-Reply-To: <20251128112307.80237-1-fushuai.wang@linux.dev> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/28/25 12:23, Fushuai Wang wrote: >>> include/linux/hugetlb.h | 8 ++++++++ >>> 1 file changed, 8 insertions(+) >>> >>> diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h >>> index 8e63e46b8e1f..f97cb2f123a3 100644 >>> --- a/include/linux/hugetlb.h >>> +++ b/include/linux/hugetlb.h >>> @@ -15,6 +15,7 @@ >>> #include >>> #include >>> #include >>> +#include >>> >>> struct ctl_table; >>> struct user_struct; >>> @@ -468,6 +469,13 @@ static inline void hugetlb_split(struct vm_area_struct *vma, unsigned long addr) >>> >>> #endif /* !CONFIG_HUGETLB_PAGE */ >>> >>> +DEFINE_GUARD(hugetlb_vma_read, struct vm_area_struct *, >>> + hugetlb_vma_lock_read(_T), hugetlb_vma_unlock_read(_T)) >>> + >>> +DEFINE_GUARD(hugetlb_vma_write, struct vm_area_struct *, >>> + hugetlb_vma_lock_write(_T), hugetlb_vma_unlock_write(_T)) >>> +DEFINE_GUARD_COND(hugetlb_vma_write, _try, hugetlb_vma_trylock_write(_T)) >> >> Do I understand correctly that the code you are introducing does not >> have any users? > > Yes, it is not used now, but it can be used in future development to simplify > the code. If there are complex hugetlb_vma locks in the current code, this can > also be used later to optimize them. Right, but we usually don't add dead code. So it should ideally be introduced with actual users. -- Cheers David