Re: [PATCH 2/2] mm/memory-failure: use bool for forcekill state
From: Ye Liu
Date: Fri Apr 10 2026 - 03:17:58 EST
在 2026/4/10 14:45, Miaohe Lin 写道:
> On 2026/4/7 10:07, Ye Liu wrote:
>> From: Ye Liu <liuye@xxxxxxxxxx>
>>
>> 'forcekill' is used as a boolean flag to control whether
>> processes should be forcibly killed. It is only assigned
>> from boolean expressions and never used in arithmetic or
>> bitmask operations.
>>
>> Convert it from int to bool.
>>
>> No functional change intended.
>>
>> Signed-off-by: Ye Liu <liuye@xxxxxxxxxx>
>> ---
>> mm/memory-failure.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index d25adb390c3e..f355642bc2b6 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -459,7 +459,7 @@ void add_to_kill_ksm(struct task_struct *tsk, const struct page *p,
>> * Only do anything when FORCEKILL is set, otherwise just free the
>> * list (this is used for clean pages which do not need killing)
>> */
>> -static void kill_procs(struct list_head *to_kill, int forcekill,
>> +static void kill_procs(struct list_head *to_kill, bool forcekill,
>> unsigned long pfn, int flags)
>> {
>> struct to_kill *tk, *next;
>> @@ -1582,7 +1582,7 @@ static bool hwpoison_user_mappings(struct folio *folio, struct page *p,
>> {
>> LIST_HEAD(tokill);
>> bool unmap_success;
>> - int forcekill;
>> + bool forcekill;
>> bool mlocked = folio_test_mlocked(folio);
>
> There is one caller in unmap_and_kill():
> kill_procs(to_kill, flags & MF_MUST_KILL, pfn, flags);
>
> It seems flags & MF_MUST_KILL does not return bool. So maybe we should change it
> to clear semantic conversion?
>
Thanks, that's a good point.
While the current call relies on the implicit scalar-to-bool conversion,
making it explicit at the call site better reflects the intent of this bool conversion cleanup.
I'll switch it to `!!(flags & MF_MUST_KILL)` in v2 for clarity.
Appreciate the review.
> Thanks.
> .
--
Thanks,
Ye Liu