From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EAC2C433F5 for ; Mon, 16 May 2022 02:00:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEB686B0073; Sun, 15 May 2022 22:00:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D99816B0075; Sun, 15 May 2022 22:00:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C62766B0078; Sun, 15 May 2022 22:00:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id B6CE16B0073 for ; Sun, 15 May 2022 22:00:49 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 8ACCA808B7 for ; Mon, 16 May 2022 02:00:49 +0000 (UTC) X-FDA: 79469952618.03.3EF71F1 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by imf12.hostedemail.com (Postfix) with ESMTP id D78D2400AE for ; Mon, 16 May 2022 02:00:21 +0000 (UTC) Received: from canpemm500002.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4L1j5N2m5zzCsmV; Mon, 16 May 2022 09:55:52 +0800 (CST) Received: from [10.174.177.76] (10.174.177.76) by canpemm500002.china.huawei.com (7.192.104.244) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 16 May 2022 10:00:44 +0800 Subject: Re: [PATCH 06/15] mm/swap: remove buggy cache->nr check in refill_swap_slots_cache To: David Hildenbrand , CC: , , , , , , , , , References: <20220509131416.17553-1-linmiaohe@huawei.com> <20220509131416.17553-7-linmiaohe@huawei.com> From: Miaohe Lin Message-ID: <8b03aa8a-5023-6915-64c6-f6f298f19f36@huawei.com> Date: Mon, 16 May 2022 10:00:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.76] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To canpemm500002.china.huawei.com (7.192.104.244) X-CFilter-Loop: Reflected X-Stat-Signature: 43sg18xrc1x4gkobc4zizwokzjxs8ij7 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: D78D2400AE X-Rspam-User: Authentication-Results: imf12.hostedemail.com; dkim=none; spf=pass (imf12.hostedemail.com: domain of linmiaohe@huawei.com designates 45.249.212.189 as permitted sender) smtp.mailfrom=linmiaohe@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1652666421-171924 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 2022/5/12 21:37, David Hildenbrand wrote: > On 09.05.22 15:14, Miaohe Lin wrote: >> refill_swap_slots_cache is always called when cache->nr is 0. And if >> cache->nr != 0, we should return cache->nr instead of 0. So remove >> such buggy and confusing check. > > Not sure about the "cache->nr != 0, we should return cache->nr instead > of 0" part, I'd just drop that from the patch description. We'd actually > end up overwriting cache->nr after your change, which doesn't sound > right and also different to what you describe here. Will do. > >> >> Signed-off-by: Miaohe Lin >> --- >> mm/swap_slots.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/mm/swap_slots.c b/mm/swap_slots.c >> index 2f877e6f87d7..2a65a89b5b4d 100644 >> --- a/mm/swap_slots.c >> +++ b/mm/swap_slots.c >> @@ -258,7 +258,7 @@ void enable_swap_slots_cache(void) >> /* called with swap slot cache's alloc lock held */ >> static int refill_swap_slots_cache(struct swap_slots_cache *cache) >> { >> - if (!use_swap_slot_cache || cache->nr) >> + if (!use_swap_slot_cache) >> return 0; >> >> cache->cur = 0; > > I feel like if this function would be called with cache->nr, it would be > a BUG. So I'm fine with removing it, but we could also think about > turning it into some sort of WARN/BG to make it clearer that this is > unexpected. Since refill_swap_slots_cache is only called by folio_alloc_swap when cache->nr == 0. I think it might be too overkill to add a WARN/BG. > > > Anyhow, > > Acked-by: David Hildenbrand Many thanks for comment and Acked-by tag! >