[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <404e6c17-dd1f-84f9-86ca-8a39cbdbffd1@huawei.com>
Date: Thu, 14 Jan 2021 10:34:57 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Matthew Wilcox <willy@...radead.org>
CC: <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] mm/swap_slots.c: Remove unnecessary NULL pointer check
Hi:
On 2021/1/10 1:40, Matthew Wilcox wrote:
> On Sat, Jan 09, 2021 at 03:09:43AM -0500, Miaohe Lin wrote:
>> The cache->slots and cache->slots_ret is already checked before we try to
>> drain it. And kvfree can handle the NULL pointer itself. So remove the
>> NULL pointer check here.
>
>> @@ -178,7 +178,7 @@ static void drain_slots_cache_cpu(unsigned int cpu, unsigned int type,
>> swapcache_free_entries(cache->slots + cache->cur, cache->nr);
>> cache->cur = 0;
>> cache->nr = 0;
>> - if (free_slots && cache->slots) {
>> + if (free_slots) {
>
> Prove that swapcache_free_entries() doesn't change cache->slots.
>
Yeh... I see. I thought swap_slots_cache_mutex could totally guard against this.
>> @@ -188,13 +188,12 @@ static void drain_slots_cache_cpu(unsigned int cpu, unsigned int type,
>> spin_lock_irq(&cache->free_lock);
>> swapcache_free_entries(cache->slots_ret, cache->n_ret);
>> cache->n_ret = 0;
>> - if (free_slots && cache->slots_ret) {
>> + if (free_slots) {
>
> ... or ->slots_ret
>
>> - if (slots)
>> - kvfree(slots);
>> + kvfree(slots);
>
> This is fine.
> .
>
Many thanks for your review and reply!
Powered by blists - more mailing lists