From patchwork Fri May 1 01:52:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11522007 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CCB4C913 for ; Fri, 1 May 2020 01:53:17 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 94B2E20873 for ; Fri, 1 May 2020 01:53:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OD86UNg7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94B2E20873 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id C741F8E0005; Thu, 30 Apr 2020 21:53:16 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id BFE048E0001; Thu, 30 Apr 2020 21:53:16 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AED918E0005; Thu, 30 Apr 2020 21:53:16 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0201.hostedemail.com [216.40.44.201]) by kanga.kvack.org (Postfix) with ESMTP id 92F918E0001 for ; Thu, 30 Apr 2020 21:53:16 -0400 (EDT) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 577C9181AEF07 for ; Fri, 1 May 2020 01:53:16 +0000 (UTC) X-FDA: 76766477592.08.magic99_90f4b43989f37 X-Spam-Summary: 2,0,0,06ff0d83847a4fba,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1541:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2692:2731:3138:3139:3140:3141:3142:3353:3865:3866:3867:3868:3870:3871:3872:5007:6261:6653:7514:7903:9413:10004:11026:11473:11658:11914:12296:12297:12517:12519:12555:12895:13069:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30054:30070:30090,0,RBL:209.85.208.65:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: magic99_90f4b43989f37 X-Filterd-Recvd-Size: 4450 Received: from mail-ed1-f65.google.com (mail-ed1-f65.google.com [209.85.208.65]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 01:53:16 +0000 (UTC) Received: by mail-ed1-f65.google.com with SMTP id k22so6224229eds.6 for ; Thu, 30 Apr 2020 18:53:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=j9Kda2ZMzERIfmoRsalDd4Qs7A9RvCefihNSzH/my34=; b=OD86UNg78ivHDmdcvDqv2BI4SX/8T8Rl+eFOo4cj6J9tw4UBjxoYDgcJVRoe/s3ZNE REWAULHQz46aNm3X73Kous/fi2h25vtE16oQjf+Dmj7RnV/BVAMs9iRHQZcwXAusHtqq 2WnRMTICOfsOQM4T486+Sc5qmmSqZD4mMOoq3XqKevPEC6aharuMDZ2W4s7VF2ckhmya 4QByGdyGSUYnXHOkfzTk6DkJK6aiSryPa9LAt/J1qxZgZBHjAYVUWznK70EYzKOy/SFH EM2mZOl6O9IdDXsMnUeiNYW4KADz5EwkpY23HBg/g2gHuFUe+Ss67d8RDwNMPTllz1ib b2dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=j9Kda2ZMzERIfmoRsalDd4Qs7A9RvCefihNSzH/my34=; b=OML9tGNnHiufbupi3GDdIhpYmzX6XSUTbMuSK3mY4CxNw+cfwL26JocyjNkZFVGchp M2CpRr2RHEgWeRg6B5hQsYOF5rbHwrgGQpZiBB800YjLvnOvpXQ84NRq5Rr+So4xCop0 mwdi0+i6y5Yu9NvYZ2dTAYhR0WJzNB7tsGEe6rcNP8zhBq1AsxtyLsUlpD4FVu23x7a5 ixsgHrdyljMHTVgSR+k9l1T0Zq2kIxAq+2NCGYE1e6x6flPkHKbOPrr8NaQDSxr1rtc6 yeU1URnz3dHcbm9w26bFT5WKikG7BcG4Dwu4YUk47dJqtQIPvhqiQ9d6Pzl92MilaaRG IIaA== X-Gm-Message-State: AGi0PuY+RJPQyioQKUXSPaSHTpvYiu/ITaZUQg7HMj0YECMoeLEwYs2s TmcdVjdOF/a0VwISf5jWks8= X-Google-Smtp-Source: APiQypISfC9xoj/GtBzBklPyzxul23IZsdu7YUppY2oWHs6suogoxtNDpwtr/QjuP/+4F4OUbYX3MQ== X-Received: by 2002:a05:6402:22d5:: with SMTP id dm21mr1585390edb.275.1588297994845; Thu, 30 Apr 2020 18:53:14 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id ss26sm171284ejb.70.2020.04.30.18.53.13 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Apr 2020 18:53:14 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, ying.huang@intel.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH 1/3] mm/swapfile.c: classify SWAP_MAP_XXX to make it more readable Date: Fri, 1 May 2020 01:52:57 +0000 Message-Id: <20200501015259.32237-1-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 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: swap_info_struct->swap_map[] encodes some flag and count. And to do some condition check, it also introduces some special values. Currently those macros are defined with some magic order, which makes audience hard to understand the exact meaning. This patch split those macros into three categories: flag special value for first swap_map special value for continued swap_map May this help audiences a little. Signed-off-by: Wei Yang --- include/linux/swap.h | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/include/linux/swap.h b/include/linux/swap.h index 1e99f7ac1d7e..ec507c67529b 100644 --- a/include/linux/swap.h +++ b/include/linux/swap.h @@ -183,12 +183,17 @@ enum { #define SWAP_CLUSTER_MAX 32UL #define COMPACT_CLUSTER_MAX SWAP_CLUSTER_MAX -#define SWAP_MAP_MAX 0x3e /* Max duplication count, in first swap_map */ -#define SWAP_MAP_BAD 0x3f /* Note pageblock is bad, in first swap_map */ +/* Bit flag in swap_map */ #define SWAP_HAS_CACHE 0x40 /* Flag page is cached, in first swap_map */ -#define SWAP_CONT_MAX 0x7f /* Max count, in each swap_map continuation */ -#define COUNT_CONTINUED 0x80 /* See swap_map continuation for full count */ -#define SWAP_MAP_SHMEM 0xbf /* Owned by shmem/tmpfs, in first swap_map */ +#define COUNT_CONTINUED 0x80 /* Flag swap_map continuation for full count */ + +/* Special Value in first swap_map */ +#define SWAP_MAP_MAX 0x3e /* Max count */ +#define SWAP_MAP_BAD 0x3f /* Note page is bad */ +#define SWAP_MAP_SHMEM 0xbf /* Owned by shmem/tmpfs */ + +/* Special Value in each swap_map continuation */ +#define SWAP_CONT_MAX 0x7f /* Max count */ /* * We use this to track usage of a cluster. A cluster is a block of swap disk From patchwork Fri May 1 01:52:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11522009 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFAFD913 for ; Fri, 1 May 2020 01:53:19 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8BDDD2074A for ; Fri, 1 May 2020 01:53:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IklgJ3X+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8BDDD2074A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AF1778E0006; Thu, 30 Apr 2020 21:53:17 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A521A8E0001; Thu, 30 Apr 2020 21:53:17 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CC7C8E0006; Thu, 30 Apr 2020 21:53:17 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0058.hostedemail.com [216.40.44.58]) by kanga.kvack.org (Postfix) with ESMTP id 71AF38E0001 for ; Thu, 30 Apr 2020 21:53:17 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 343A2180AD80F for ; Fri, 1 May 2020 01:53:17 +0000 (UTC) X-FDA: 76766477634.21.nest72_9112db65b7a25 X-Spam-Summary: 2,0,0,47a97faba893ec09,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:965:966:968:973:988:989:1260:1345:1359:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:4321:4385:4390:4395:4605:5007:6261:6653:7514:9413:10004:11026:11473:11658:11914:12043:12297:12438:12517:12519:12555:12895:13069:13311:13357:14096:14181:14384:14394:14687:14721:21080:21444:21627:21666:30054,0,RBL:209.85.208.66:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: nest72_9112db65b7a25 X-Filterd-Recvd-Size: 4245 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf17.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 01:53:16 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id k22so6224259eds.6 for ; Thu, 30 Apr 2020 18:53:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qmO2teDKNVVM1SwTPbEO3I1g0qYZy8+bZ8T5vEIKOEA=; b=IklgJ3X+Nn1j2h4folWHbFv3GAF2mbpLt8qjUfZ6kM5BtiPNTD7swT8UthYE09my8B IdfjfoxhHKiu9+Hj9cHuEep5hOAV5j0d8z3oM1FctJ8QcLiZLU2QyHIc7hOd8/6Ffsma 4DxurCOjIu31jMBHVXUVvU5/qHn3RlY3PAoduJ/YHDI7lltf1EakLiHEjuSlh41JZfDy Ed0JaQ6FhIj7sIRGAHGop49RLpmKu/Za8gJ52ssiQPcb5XV+VU66G9x/E0XqanK5ztVq kbY3nBP0kcDPQ61ajaMGdy+Uk+kKanjsfYQDCAdMz5d4s8TznqGeZe7nsvymw6lX+Plo KulQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qmO2teDKNVVM1SwTPbEO3I1g0qYZy8+bZ8T5vEIKOEA=; b=V5ai0A8a2miYYxl7TtTdrOqDrFJQZ9dmqYsVBMnWL9+dqlIt1x/maWZ/uNJND1FzLc 7jlIQGqyX5s2cXYOTu14UYWbfLwOxr6K4B/4l+Ej4AJI8hXfnd9pbJ7qptqjXj9PKVeh RhmxjMyEEwfEgkw7phR1Mn4U3Rke1h24hJHcjqBzQLapH9x+guKsI5kTUZZ6vgNZWVjA yKt/vgRGw+qVAmD5FAsJMskI35QrXwEpfIrj46LD9HR7sho5VxL9jXKUN/JAqpEH9UsL oXbCacZo2HKiE4BDaGJEunuHabTRQb5xwA5/+kMlGv33ezW9pn+TbtssXlU0Uw/Hmh3h QpJQ== X-Gm-Message-State: AGi0PuajmLmX2ZWzg+ZHooYH0L/lfMvpVlETPKBMEY1SW567FmTJ2AU7 wL9lu/DU17qBR7AXk9SoP8I= X-Google-Smtp-Source: APiQypIq9ryOlak/rz39kcVg8Q7gUgSUakpIFnzLSrGRze3GlvQuw8lQICCABQYv3QaFwSjh/f3KvA== X-Received: by 2002:aa7:d9d8:: with SMTP id v24mr1605224eds.27.1588297995873; Thu, 30 Apr 2020 18:53:15 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id n17sm165098eja.9.2020.04.30.18.53.15 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Apr 2020 18:53:15 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, ying.huang@intel.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH 2/3] mm/swapfile.c: __swap_entry_free() always free 1 entry Date: Fri, 1 May 2020 01:52:58 +0000 Message-Id: <20200501015259.32237-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200501015259.32237-1-richard.weiyang@gmail.com> References: <20200501015259.32237-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000300, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: __swap_entry_free() always free 1 entry, let's remove the usage. Signed-off-by: Wei Yang --- mm/swapfile.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index f73e0c11fab9..1a877d1d40e3 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1251,13 +1251,14 @@ struct swap_info_struct *get_swap_device(swp_entry_t entry) } static unsigned char __swap_entry_free(struct swap_info_struct *p, - swp_entry_t entry, unsigned char usage) + swp_entry_t entry) { struct swap_cluster_info *ci; unsigned long offset = swp_offset(entry); + unsigned char usage; ci = lock_cluster_or_swap_info(p, offset); - usage = __swap_entry_free_locked(p, offset, usage); + usage = __swap_entry_free_locked(p, offset, 1); unlock_cluster_or_swap_info(p, ci); if (!usage) free_swap_slot(entry); @@ -1292,7 +1293,7 @@ void swap_free(swp_entry_t entry) p = _swap_info_get(entry); if (p) - __swap_entry_free(p, entry, 1); + __swap_entry_free(p, entry); } /* @@ -1715,7 +1716,7 @@ int free_swap_and_cache(swp_entry_t entry) p = _swap_info_get(entry); if (p) { - count = __swap_entry_free(p, entry, 1); + count = __swap_entry_free(p, entry); if (count == SWAP_HAS_CACHE && !swap_page_trans_huge_swapped(p, entry)) __try_to_reclaim_swap(p, swp_offset(entry), From patchwork Fri May 1 01:52:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11522011 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D095792A for ; Fri, 1 May 2020 01:53:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D72B24957 for ; Fri, 1 May 2020 01:53:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OHcfllwj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D72B24957 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id BB28A8E0007; Thu, 30 Apr 2020 21:53:18 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id B3F068E0001; Thu, 30 Apr 2020 21:53:18 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 943E38E0007; Thu, 30 Apr 2020 21:53:18 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0148.hostedemail.com [216.40.44.148]) by kanga.kvack.org (Postfix) with ESMTP id 75FF48E0001 for ; Thu, 30 Apr 2020 21:53:18 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3F5CE180AD80F for ; Fri, 1 May 2020 01:53:18 +0000 (UTC) X-FDA: 76766477676.14.sun12_913bf6b797108 X-Spam-Summary: 2,0,0,f2f87de6e848bb1e,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1359:1437:1534:1540:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3352:3865:3868:3870:3871:5007:6261:6653:7514:7903:8784:9413:10004:11026:11473:11658:11914:12297:12438:12517:12519:12555:12895:13069:13161:13229:13311:13357:14181:14384:14394:14687:14721:21080:21444:21627:21666:30054,0,RBL:209.85.208.66:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:19,LUA_SUMMARY:none X-HE-Tag: sun12_913bf6b797108 X-Filterd-Recvd-Size: 3781 Received: from mail-ed1-f66.google.com (mail-ed1-f66.google.com [209.85.208.66]) by imf10.hostedemail.com (Postfix) with ESMTP for ; Fri, 1 May 2020 01:53:17 +0000 (UTC) Received: by mail-ed1-f66.google.com with SMTP id k22so6224296eds.6 for ; Thu, 30 Apr 2020 18:53:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=L/eixiBO7KCR17cAG5IpTeBZCnCmuzeLdJS3OmBcd98=; b=OHcfllwjxxUFVat65zUUPNoQ+blqGZIuFQY+SiYeTzQySOJAGsJaSBgC/RoNSdkGxV D01pDAx4vQZvw2wc/bBohb/fhhJNztvgMx0d88aD6/mO+CJBwze+BPlV1Nh2tyvDyz+2 ClU7/DYC7B667QLAnGkXcLM+lVi19nDprnUybTb+YKrZREQ7nC6+Ni1PG7I6/z/uNQRr iFzzvs4QNHpUyT2P0LQ8MGq+N9ZrCAiOl289EmSCSOeK0vdHhmU5tLv9rGD76hJLNKXc oRLYklmIIz8z4sy3vGPSGQV+AR92ZX04nkEjVYq9WvQlmWMQyd8YfTJzWGMOLQVi3jk8 KwtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=L/eixiBO7KCR17cAG5IpTeBZCnCmuzeLdJS3OmBcd98=; b=Br+nAcV7NFSDOupKJi21cG3c+J5A0o5KtZMhmDOnYBxlvlF5tPOPS14IysWYNgpwr1 nlm4ICRUFoqUmhiNVdmYfZ1Y1a3phPlWJV5o620QN/jFMYNNLGxf3Vvmoq1losg6eHeR TGnClMoHkiPGFZVGxisr3Q0CTeQsGBt/ibIeoPg8pkVy8bTQ4ApVtMF11f+ruHU1wMnI pAN1hEhluVWmOsYa8ocowf9+dAWUaYRb1G7OKu4ttQkZCWRilrCZiOaXds3m7IWBO9du n5pYujLNL8dGQ4/EKIaO3HBK3G2liQL8NARppZy95lrrdAZM75ne4bqgCa9O5MGbcT89 8XBw== X-Gm-Message-State: AGi0PubDM1+dqzGKyUcw+0bWk52OFJXPJffXuHQQJdoIiy1BxALO+kv3 yq8PNaK7OqQudV1Tv4rYIRZ6yYf62GM= X-Google-Smtp-Source: APiQypI6ocw5DBnFfrafoO2PU1kyqVt3eWL/xIIEWqyvGX1ib44xvQchsw21+chYGqWBRVj8xXX68g== X-Received: by 2002:a05:6402:887:: with SMTP id e7mr1745347edy.178.1588297996991; Thu, 30 Apr 2020 18:53:16 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id g1sm170066ejs.51.2020.04.30.18.53.16 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Apr 2020 18:53:16 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org, ying.huang@intel.com Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Wei Yang Subject: [PATCH 3/3] mm/swapfile.c: count won't be bigger than SWAP_MAP_MAX Date: Fri, 1 May 2020 01:52:59 +0000 Message-Id: <20200501015259.32237-3-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200501015259.32237-1-richard.weiyang@gmail.com> References: <20200501015259.32237-1-richard.weiyang@gmail.com> X-Bogosity: Ham, tests=bogofilter, spamicity=0.015794, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: When the condition is true, there are two possibilities: 1. count == SWAP_MAP_BAD 2. count == (SWAP_MAP_MAX & COUNT_CONTINUED) == SWAP_MAP_SHMEM The first case would be filtered by the first if in __swap_duplicate(). And the second case means this swap entry is for shmem. Since we never do another duplication for shmem swap entry. This won't happen neither. Signed-off-by: Wei Yang --- mm/swapfile.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 1a877d1d40e3..88dd2ad34aad 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -3404,8 +3404,6 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage) if ((count & ~COUNT_CONTINUED) < SWAP_MAP_MAX) count += usage; - else if ((count & ~COUNT_CONTINUED) > SWAP_MAP_MAX) - err = -EINVAL; else if (swap_count_continued(p, offset, count)) count = COUNT_CONTINUED; else