Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp2256909ybh; Mon, 9 Mar 2020 02:11:43 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsgHvu1LfGM09+54A+xguKtjzqx9N0x/McFe+wg3t4e1vYI+TzZB7BTmpu7gpcNkVFguoOD X-Received: by 2002:a9d:5e8b:: with SMTP id f11mr12430707otl.110.1583745102952; Mon, 09 Mar 2020 02:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583745102; cv=none; d=google.com; s=arc-20160816; b=DTouob7eS2U9kVSk1v+YgrZt65J4b1XWJX+lwr7GyHMvBwD81OTofw0RcH0rPIYS52 Q1eNXgVIWcX0c8tCGYBW5Vi2MEEFVXuWoKVImXsdFf8BXk1ggiZsWspElwN3v+MutSR9 KQBGusgJ8LFNIoh1rxP9iaOHV3mEphfWaX4fyT2l7YKK06Ia7lDloGOZYpTkO3v2egGx sPG4JuMQ+jT+BB7SQ5BgIHlHQIfvK3UR8DtPBePQMz0x5dKW53vFRdR6ej9WRWVicHEW ujoHhmemYF2whgGQu90M3+NiRxafP2TXx5JmQuYj6Hi+kNdg5cuvzR9Rvzt4rf30jp2R YnKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=gx8U9AMwuprljIObrOt7DZb0d+DzYzveHNMjG4rUQK4=; b=q4UQNfV/MYpZn14gqrh99362DLzzLpMl2gloJmp/XWQjAh4wfnpcNzLG2hF5mdkZi+ mmERubovz7sVhqSXEhF/h+8a2T+y2fiMzZgc4MngGfNX9lwvVA0+4Rd5NqKdO0WuoPEK LHVXuQyPS+CVkTvzmre0ZtWGgkHGLYt5VCRwh99PTh43CPNJPxRtuMoodKAix0krxwqu 4gcGEPVDiYPzbuouNsy4MZjA1OrNVSlHLIQ5Fo6SYk0SLP94AqL3orMXI2lwIvHRQwdp hR77ZJ2Q6NwF4aZZkNWk/6K6GMDwfMon6enLHE5p52L11zyAwYtsoBLETCSzc7VkHh/a UGUw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m11si6033710otp.174.2020.03.09.02.11.30; Mon, 09 Mar 2020 02:11:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726414AbgCIJKJ (ORCPT + 99 others); Mon, 9 Mar 2020 05:10:09 -0400 Received: from out30-45.freemail.mail.aliyun.com ([115.124.30.45]:34336 "EHLO out30-45.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726071AbgCIJKJ (ORCPT ); Mon, 9 Mar 2020 05:10:09 -0400 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R731e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01f04396;MF=richard.weiyang@linux.alibaba.com;NM=1;PH=DS;RN=4;SR=0;TI=SMTPD_---0Ts2w.vr_1583745003; Received: from localhost(mailfrom:richard.weiyang@linux.alibaba.com fp:SMTPD_---0Ts2w.vr_1583745003) by smtp.aliyun-inc.com(127.0.0.1); Mon, 09 Mar 2020 17:10:03 +0800 From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH] mm/swap_slots.c: don't reset the cache slot after use Date: Mon, 9 Mar 2020 17:09:40 +0800 Message-Id: <20200309090940.34130-1-richard.weiyang@linux.alibaba.com> X-Mailer: git-send-email 2.20.1 (Apple Git-117) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently we would clear the cache slot if it is used. While this is not necessary, since this entry would not be used until refilled. Leave it untouched and assigned the value directly to entry which makes the code little more neat. Also this patch merges the else and if, since this is the only case we refill and repeat swap cache. Signed-off-by: Wei Yang --- mm/swap_slots.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mm/swap_slots.c b/mm/swap_slots.c index 63a7b4563a57..ff695df3db26 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c @@ -309,7 +309,7 @@ int free_swap_slot(swp_entry_t entry) swp_entry_t get_swap_page(struct page *page) { - swp_entry_t entry, *pentry; + swp_entry_t entry; struct swap_slots_cache *cache; entry.val = 0; @@ -336,13 +336,10 @@ swp_entry_t get_swap_page(struct page *page) if (cache->slots) { repeat: if (cache->nr) { - pentry = &cache->slots[cache->cur++]; - entry = *pentry; - pentry->val = 0; + entry = cache->slots[cache->cur++]; cache->nr--; - } else { - if (refill_swap_slots_cache(cache)) - goto repeat; + } else if (refill_swap_slots_cache(cache)) { + goto repeat; } } mutex_unlock(&cache->alloc_lock); -- 2.20.1 (Apple Git-117)