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