From patchwork Wed Mar 25 22:03:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11458753 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 EC7FC913 for ; Wed, 25 Mar 2020 22:03:27 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B648720B80 for ; Wed, 25 Mar 2020 22:03:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WYC6c5VQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B648720B80 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 D06436B0008; Wed, 25 Mar 2020 18:03:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C8F986B000A; Wed, 25 Mar 2020 18:03:26 -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 B57696B000C; Wed, 25 Mar 2020 18:03:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 9A2EC6B0008 for ; Wed, 25 Mar 2020 18:03:26 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A1BC41804474A for ; Wed, 25 Mar 2020 22:03:26 +0000 (UTC) X-FDA: 76635261612.13.owl86_754a055438a4c X-Spam-Summary: 2,0,0,74374a289e3ccdc4,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1345:1437:1534:1539:1568:1711:1714:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3865:3867:3868:3872:4321:5007:6261:6653:7514:8603:9413:9592:10004:11026:11658:11914:12297:12517:12519:12555:12895:12986:13069:13311:13357:14181:14384:14394:14687:14721:21080:21444:21627:21666:30054,0,RBL:209.85.221.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:24,LUA_SUMMARY:none X-HE-Tag: owl86_754a055438a4c X-Filterd-Recvd-Size: 3300 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf12.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 22:03:25 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id h15so5401309wrx.9 for ; Wed, 25 Mar 2020 15:03:25 -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=agvIO6IAC74tbDrcVh+mwo/yT2bxjnoGYoZ36w/G8wI=; b=WYC6c5VQO1ju237T5Q+oZJnUvpwVU6UMDzPNqJoZ5i3WQHvpLkSUaHlVBlt0snttNR JaWW25ZiFwHJAFBSfD9+H/EP0RDZY4p/pjzjZVw1Jv7nyt+HdR7plTSucKqgBqGKNuTR dC5yA9JG3lYDvia6iSH8j5rLsayQrK9ot8A1pL7llwKk5A0uytgrKoDeA7+BxEtzzlPP +wHlweCpXRNSLtDGijcTK/lB6R6IN1avAmitao49Axw7j7uWK6zbL7zHJZxkqNMOy1EA g1bGCHHNF2xJKaaDKvuC9WO+MA7eRiMtZRDlZAp40w+KhwpXeS4Zv6YOGGdEu1BuRpSI T4cg== 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=agvIO6IAC74tbDrcVh+mwo/yT2bxjnoGYoZ36w/G8wI=; b=nlYCR+Q3EbodYgTxeQFcKeMbJhpx+r4sH+1GlWy1V5oGWJD9RxrshDf11Ggn2WBeZt cMblfJ/ZYTnNunhu/lGiQmcIR7i7A1685lTj9ERJR1OYkkiv+MOAfDd2W6/g4JIcKcDp FbutLKw70uo8IpBt0WthLkwEVZILIxRNoDr5N85Dv3r2jhOtuynGlMhB/jenG8gvALgu gvM3DpvciccmIOtY85Z+u7Jc+te5IPblkr2yHZ3LiWJ5yWegjbZNuzUWFfIdUP03O+qf G32uve8eaTeSPWsLz4jk39BcQc8xGPCFdJaF/Bm/JkrftKgNOIV1F4Mp37mK8R6njHaF 8MjA== X-Gm-Message-State: ANhLgQ3fC9xbX0pE+zj3CqEOAoq8TMMIzgkpm8BLcXhCA1SINQj+ov1+ BNrK//0i394cVrveYdZI5Ss= X-Google-Smtp-Source: ADFU+vuBltj8DZBlHNgYky+cwNcndJJYwg6qRPvBFLxAZRgw/+d63+IXqaflixa3ETgMJ0d8z1JPrg== X-Received: by 2002:adf:83c4:: with SMTP id 62mr6015181wre.105.1585173804669; Wed, 25 Mar 2020 15:03:24 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id y200sm567990wmc.20.2020.03.25.15.03.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Mar 2020 15:03:24 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 1/2] mm/swapfile.c: simplify the calculation of n_goal Date: Wed, 25 Mar 2020 22:03:08 +0000 Message-Id: <20200325220309.9803-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: Use min3() to simplify the comparison and make it more self-explaining. Signed-off-by: Wei Yang --- mm/swapfile.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 2c33ff456ed5..85b151d73128 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -1004,11 +1004,7 @@ int get_swap_pages(int n_goal, swp_entry_t swp_entries[], int entry_size) if (avail_pgs <= 0) goto noswap; - if (n_goal > SWAP_BATCH) - n_goal = SWAP_BATCH; - - if (n_goal > avail_pgs) - n_goal = avail_pgs; + n_goal = min3((long)n_goal, (long)SWAP_BATCH, avail_pgs); atomic_long_sub(n_goal * size, &nr_swap_pages); From patchwork Wed Mar 25 22:03:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yang X-Patchwork-Id: 11458755 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 53965913 for ; Wed, 25 Mar 2020 22:03:33 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2060F20719 for ; Wed, 25 Mar 2020 22:03:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="b8hwkqNq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2060F20719 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 58C096B000A; Wed, 25 Mar 2020 18:03:32 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 5154E6B000C; Wed, 25 Mar 2020 18:03:32 -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 3DFA56B000D; Wed, 25 Mar 2020 18:03:32 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0149.hostedemail.com [216.40.44.149]) by kanga.kvack.org (Postfix) with ESMTP id 2703C6B000A for ; Wed, 25 Mar 2020 18:03:32 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 46BA15B7FB for ; Wed, 25 Mar 2020 22:03:32 +0000 (UTC) X-FDA: 76635261822.25.feast40_7628be7207234 X-Spam-Summary: 2,0,0,25e47902769700b8,d41d8cd98f00b204,richard.weiyang@gmail.com,,RULES_HIT:41:355:379:541:800:960:968:973:988:989:1260:1345:1359:1437:1534:1539:1711:1714:1730:1747:1777:1792:2393:2559:2562:2903:3138:3139:3140:3141:3142:3351:3867:3868:3870:3871:3872:4321:5007:6119:6261:6653:7514:7903:9413:9592:10004:11026:11658:11914:12114:12296:12297:12517:12519:12555:12895:13069:13311:13357:14181:14384:14394:14687:14721:21080:21444:21627:21666:30054:30070,0,RBL:209.85.221.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: feast40_7628be7207234 X-Filterd-Recvd-Size: 3512 Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by imf44.hostedemail.com (Postfix) with ESMTP for ; Wed, 25 Mar 2020 22:03:31 +0000 (UTC) Received: by mail-wr1-f65.google.com with SMTP id s1so5440591wrv.5 for ; Wed, 25 Mar 2020 15:03:31 -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=R49ssuqQGRjTcbw9XYqjygG4biZpQtMbehigwtsfjOM=; b=b8hwkqNqX/+hIC58/+o/jd+0hEIUCn6eGgDrCSTUGUo6c4fzZOYMEj37Roe2WBsIq2 zPqtqniduYl+UvmFPdYuneOUTIEcUghd16bL9IJqmhH7XZTTrtZuQfFuLW/rgoeJOIZi KioKbDKUOjj1HE5tnVJk5cA1RODuS8ThgUlXbJzegQlwTT2tHHyq166tWty1RcqiWiOA 4iVYzWAU/BjXIhlpyTreOQLqfAVOdvZkQrU15XbQbZof9bm3wZaUN34MCo6SojmQ5pSx U5iDZ6m7UARO56gdtaY4WIPX4f/p/P58rJaGF8PR5pXxxx/DuKqPmOlSyUprBt78MJkD zVAw== 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=R49ssuqQGRjTcbw9XYqjygG4biZpQtMbehigwtsfjOM=; b=PiFurs4ZA/VT2+F2rJL5zQ1k+1dKWSE13ryztUGn/zOVjSLhfZ6eUvl3LOHJk3cb4e BbRFiRh9SylKt+/JaUOjxl6uc0kG0Uc9wfOKNhN8rBXmeWEb94R6yqgPpiNYV3a/1JnK dNcnWGKvAUWWDHu8ZXT5GAgAv07B7l0TSPh18dx6hR+bgBC4Ktz5QJ2FQI56uuWe4DSv x24ILKkqdXntbtRXPxjj6LuqtTDepW2fHb/AKC8b001nRkdBvZfZ77Vcn1nfnKC8YbWY S+QNSO/H5Bdz5ztQ135uNc5HfJru8ipgD7P7XoObxy5GUnOn/UE+WtmPfYv8rwuWSeQY PEuA== X-Gm-Message-State: ANhLgQ2DWAdcbo7jvoXI3Q9xXBgrKI79HpF+5W/A0dOHRExVw0bOkJVd Z2O52+ZExMQ4k3CbUmDscIU= X-Google-Smtp-Source: ADFU+vts1LWIKOZxKckKm7jY1vK/lIgif1ns7ncn3MUnWWG+0Lwvm1lfxOUZoRF5sAbRYiKZPWNlrg== X-Received: by 2002:a05:6000:10d1:: with SMTP id b17mr5907386wrx.360.1585173810581; Wed, 25 Mar 2020 15:03:30 -0700 (PDT) Received: from localhost ([185.92.221.13]) by smtp.gmail.com with ESMTPSA id u8sm408952wrn.69.2020.03.25.15.03.29 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 25 Mar 2020 15:03:29 -0700 (PDT) From: Wei Yang To: akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Wei Yang Subject: [PATCH 2/2] mm/swapfile.c: remove the extra check in scan_swap_map_slots() Date: Wed, 25 Mar 2020 22:03:09 +0000 Message-Id: <20200325220309.9803-2-richard.weiyang@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20200325220309.9803-1-richard.weiyang@gmail.com> References: <20200325220309.9803-1-richard.weiyang@gmail.com> 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: scan_swap_map_slots() is only called by scan_swap_map() and get_swap_pages(). Both ensure nr would not exceed SWAP_BATCH. Just remove it. Signed-off-by: Wei Yang --- mm/swapfile.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/mm/swapfile.c b/mm/swapfile.c index 85b151d73128..6b6e41967bf3 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -740,9 +740,6 @@ static int scan_swap_map_slots(struct swap_info_struct *si, int latency_ration = LATENCY_LIMIT; int n_ret = 0; - if (nr > SWAP_BATCH) - nr = SWAP_BATCH; - /* * We try to cluster swap pages by allocating them sequentially * in swap. Once we've allocated SWAPFILE_CLUSTER pages this