From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E194A364032 for ; Wed, 13 May 2026 03:37:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778643429; cv=none; b=Z2skDfhKv+yduKHNYTbX1n2iiLB/HcYPQ37aWlwwuq6rg9deks8A5XY5h3QuHEoHBj7bH4kl7tF9+9XzphxpLUD/lGtajXGP4ON1O14bnltWwqGNq83AI8hIRuQjoQYoJF9V5zCKD1HOvzc6XUzIr2fS8L/lkl/870Od84RAzEc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778643429; c=relaxed/simple; bh=X7fa3A3kUwmv2leRPQ4jL+BRBf36f9OkDyT27E9u1Fw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FGQLPW2VaIDU+q3CO/zAxjihoK43J53IIhVXtGhiS3RZcCfTiTLjiTeLyolj9/y7bjVHghmvKmYo9cxGCIIKqeuZGn7WdSR/z9/Ww9O7r1GFq+OkxqDlGo6nY/T/o+Bb/kWTVtGaY8f96YlhMjcPENR1YxMlSNoZTNDoTHbTdUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Bey+WXoR; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=k7DSOWI8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=R5oHLi57; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=HM3JV/qX; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Bey+WXoR"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="k7DSOWI8"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="R5oHLi57"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="HM3JV/qX" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CBC186C257; Wed, 13 May 2026 03:37:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1778643426; h=from:from:reply-to: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=xIrVUliI2fByjlT/hi1CcJy977vyveqaasEj+ougrrQ=; b=Bey+WXoR75ytbq4WDmuqqZwTbov7wbnYhidmHQ1sFOwNfr61TKpDJhafReVfvAPao1Mhtd JDKpSBYAC4LSm+7BcgaL7/baXRjbrojGVMWjazze/95BztPdZOFHbDz2Wv8kxVKZ5ivSKu dBAAwcmUhu4qqng8qlUX9oqYSsYEe5c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1778643426; h=from:from:reply-to: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=xIrVUliI2fByjlT/hi1CcJy977vyveqaasEj+ougrrQ=; b=k7DSOWI85LtgFbX9un5fXvsL0BKYh0yAvP5HWWpKduH46JKvl9LIJmGrQPikbTKSCfJdtn lsWBs22Kd+BuZ3BA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=R5oHLi57; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b="HM3JV/qX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1778643425; h=from:from:reply-to: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=xIrVUliI2fByjlT/hi1CcJy977vyveqaasEj+ougrrQ=; b=R5oHLi57OEqSKzmWqbFL4uXHH9CUuE5OO8vNMy/T684MMDf30t9qZZVWHPr2n5cWoVDe48 ZizFpVZ89+tOIugmcnPglWxYB0wJOtc3zpgqoloROGapNliQwZNOHxDXNktP09L70JFfws Ely9NJla9ZptslIySKAjuECcqg46ejQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1778643425; h=from:from:reply-to: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=xIrVUliI2fByjlT/hi1CcJy977vyveqaasEj+ougrrQ=; b=HM3JV/qXOgA257YPyr6vc106fkbXeUTfXGoYuNB4CN1O9iFI1wtSychQ1I4UNscxM8AEOD LS85o9BWuFL+WxDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 5CA54593A9; Wed, 13 May 2026 03:37:05 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mrfLE+HxA2r1EQAAD6G6ig (envelope-from ); Wed, 13 May 2026 03:37:05 +0000 Date: Wed, 13 May 2026 05:36:59 +0200 From: Oscar Salvador To: Ye Liu Cc: Miaohe Lin , Andrew Morton , Ye Liu , Naoya Horiguchi , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [RESEND PATCH] mm/memory_failure: use bool for hugetlb indicator in try_memory_failure_hugetlb Message-ID: References: <20260513024853.65566-1-ye.liu@linux.dev> 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: <20260513024853.65566-1-ye.liu@linux.dev> X-Spam-Level: X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; FREEMAIL_CC(0.00)[huawei.com,linux-foundation.org,kylinos.cn,gmail.com,kvack.org,vger.kernel.org]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TAGGED_RCPT(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; MISSING_XM_UA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:rdns,imap1.dmz-prg2.suse.org:helo,suse.de:dkim,localhost.localdomain:mid] X-Rspamd-Queue-Id: CBC186C257 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spam-Flag: NO X-Spam-Score: -3.01 On Wed, May 13, 2026 at 10:48:52AM +0800, Ye Liu wrote: > From: Ye Liu > > The hugetlb indicator in try_memory_failure_hugetlb is a Boolean > flag, but was declared and assigned as int/0/1. Convert to `bool` > and `true`/`false` for clarity and type safety. > > - try_memory_failure_hugetlb(unsigned long pfn, int flags, bool *hugetlb) > - testcase path in memory_failure(): bool hugetlb = false > - clear semantic conversion in MF_HUGETLB_NON_HUGEPAGE > - preserve behavior (no functional change) > > Signed-off-by: Ye Liu > Acked-by: Miaohe Lin > --- > mm/memory-failure.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/mm/memory-failure.c b/mm/memory-failure.c > index 866c4428ac7e..f164fc5959f0 100644 > --- a/mm/memory-failure.c > +++ b/mm/memory-failure.c > @@ -2032,7 +2032,7 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, > * -EHWPOISON - folio or exact page already poisoned > * -EFAULT - kill_accessing_process finds current->mm null > */ > -static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb) > +static int try_memory_failure_hugetlb(unsigned long pfn, int flags, bool *hugetlb) > { > int res, rv; > struct page *p = pfn_to_page(pfn); > @@ -2040,12 +2040,12 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb > unsigned long page_flags; > bool migratable_cleared = false; > > - *hugetlb = 1; > + *hugetlb = true; > retry: > res = get_huge_page_for_hwpoison(pfn, flags, &migratable_cleared); > switch (res) { > case MF_HUGETLB_NON_HUGEPAGE: /* fallback to normal page handling */ > - *hugetlb = 0; > + *hugetlb = false; Do we really need this boolean though? Why do not simply return ENOENT when we find a non-hugetlb page, and then the caller knows that if we get ENOENT, it can proceed with normal page handling? I might be missing something, but is not the following more cleaer? diff --git a/mm/memory-failure.c b/mm/memory-failure.c index ee42d4361309..44f388df5731 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c @@ -2026,13 +2026,14 @@ int __get_huge_page_for_hwpoison(unsigned long pfn, int flags, * So some of prechecks for hwpoison (pinning, and testing/setting * PageHWPoison) should be done in single hugetlb_lock range. * Returns: - * 0 - not hugetlb, or recovered + * 0 - recovered + * -ENOENT - no hugetlb page * -EBUSY - not recovered * -EOPNOTSUPP - hwpoison_filter'ed * -EHWPOISON - folio or exact page already poisoned * -EFAULT - kill_accessing_process finds current->mm null */ -static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb) +static int try_memory_failure_hugetlb(unsigned long pfn, int flags) { int res, rv; struct page *p = pfn_to_page(pfn); @@ -2040,13 +2041,11 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb unsigned long page_flags; bool migratable_cleared = false; - *hugetlb = 1; retry: res = get_huge_page_for_hwpoison(pfn, flags, &migratable_cleared); switch (res) { case MF_HUGETLB_NON_HUGEPAGE: /* fallback to normal page handling */ - *hugetlb = 0; - return 0; + return -ENOENT; case MF_HUGETLB_RETRY: if (!(flags & MF_NO_RETRY)) { flags |= MF_NO_RETRY; @@ -2107,7 +2106,7 @@ static int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb } #else -static inline int try_memory_failure_hugetlb(unsigned long pfn, int flags, int *hugetlb) +static inline int try_memory_failure_hugetlb(unsigned long pfn, int flags) { return 0; } @@ -2386,8 +2385,11 @@ int memory_failure(unsigned long pfn, int flags) } try_again: - res = try_memory_failure_hugetlb(pfn, flags, &hugetlb); - if (hugetlb) + res = try_memory_failure_hugetlb(pfn, flags); + /* + * -ENOENT means the page we found is not hugetlb, so proceed with normal page handling + */ + if (res != -ENOENT) goto unlock_mutex; if (TestSetPageHWPoison(p)) { -- Oscar Salvador SUSE Labs