From patchwork Wed Dec 2 18:27:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 11946691 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E9795C71155 for ; Wed, 2 Dec 2020 18:27:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4411222248 for ; Wed, 2 Dec 2020 18:27:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4411222248 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 C337D6B005C; Wed, 2 Dec 2020 13:27:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BE39E6B005D; Wed, 2 Dec 2020 13:27:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AADE86B0068; Wed, 2 Dec 2020 13:27:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 96CED6B005C for ; Wed, 2 Dec 2020 13:27:47 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 5E2458249980 for ; Wed, 2 Dec 2020 18:27:47 +0000 (UTC) X-FDA: 77549175774.06.slave37_2f01697273b5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin06.hostedemail.com (Postfix) with ESMTP id 3E86E100484B4 for ; Wed, 2 Dec 2020 18:27:47 +0000 (UTC) X-HE-Tag: slave37_2f01697273b5 X-Filterd-Recvd-Size: 4444 Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Wed, 2 Dec 2020 18:27:46 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id r9so1488087pjl.5 for ; Wed, 02 Dec 2020 10:27:46 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=3zNax7Y+1Ikzzmhg7iyW9MLSCw7jdgQnq4TmPmAJA28=; b=lqgtJVieKYGe00RIy86iIPDzKFYzexsfSaJr1YoR0txN85LXyOfkwRqTWB4Yi4HbdH nW1fn6UWKm75o2mYOsdPMdaVFWvTVzYmb3IHzsTFljeNu2jYbGsayg5p/0JjFIKUy7fi EcVJnKMcNIxe8nbRgx7UFLKUrp5JpvY6Ut1jHyBgbJv0ywwGLMkwB3LRH1YWUgazYloO FyEMdudReYKkvu8AvWCzlu/nf0Y6nkMhXK3doSrKwApihvi4aJpDpKf9Y8GzIlX70gTU HrWUPyuhdv2b7Xk0Cq6TUZ/dng83s4OMzmHCh3za7c3rpSqI13eT9uaq9BIQzuKJTWHf Bs7w== 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:mime-version:content-transfer-encoding; bh=3zNax7Y+1Ikzzmhg7iyW9MLSCw7jdgQnq4TmPmAJA28=; b=Q4WFlxs4ydnSDAbD28WwQFwxc61rZveVfc5Jc1J6OtrPqAIxPmF3zhjZRdz+Lp5T6V p5MkW5uCzZxxOKZ7OckcgYdHp/h/yY6Fs69+nWb9Zxbs0jaff/CxOpAR+QCoR7r1unxA 59TAXwsZ1048crLGlFBoie2NS9CSWL64140g+0y5ZAfZrrmILrnqACjwCli1Ynhb08eR sIy8Smsy1jn7oWMzyfYx0F78xHs7Ii1R+aF9jx2pvNHrscvbOiPuFrzn/X2viQW1hZkb r11sDlmY/dsZGPSTJ+4q2MSYF8v+LT8xdbhmH2BCjNHOs8ue0vR9mmE7X3CORf6x/MMa 8crA== X-Gm-Message-State: AOAM531CVgJ7vADhxiOmAHsmHGFCepLjYJu8xgihW8sb9QRQzBNrvaCG 6N9UOQyHB/J4Cn+5bHxrkt0= X-Google-Smtp-Source: ABdhPJz1U890O+WgeLnLZND4JEg1gfgDFo2nW9DjhiZUqUmGdG+/Pm+qglOPbdvkQ2Toj/Szkz158w== X-Received: by 2002:a17:902:b691:b029:d8:ebc8:385e with SMTP id c17-20020a170902b691b02900d8ebc8385emr3855010pls.48.1606933665893; Wed, 02 Dec 2020 10:27:45 -0800 (PST) Received: from localhost.localdomain (c-73-93-239-127.hsd1.ca.comcast.net. [73.93.239.127]) by smtp.gmail.com with ESMTPSA id c6sm396906pgl.38.2020.12.02.10.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 10:27:44 -0800 (PST) From: Yang Shi To: guro@fb.com, ktkhai@virtuozzo.com, shakeelb@google.com, david@fromorbit.com, hannes@cmpxchg.org, mhocko@suse.com, akpm@linux-foundation.org Cc: shy828301@gmail.com, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] mm: vmscan: simplify nr_deferred update code Date: Wed, 2 Dec 2020 10:27:17 -0800 Message-Id: <20201202182725.265020-2-shy828301@gmail.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20201202182725.265020-1-shy828301@gmail.com> References: <20201202182725.265020-1-shy828301@gmail.com> MIME-Version: 1.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: Currently if (next_deferred - scanned) = 0, the code would just read the current nr_deferred otherwise add the delta back. Both needs atomic operation anyway, it seems there is not too much gain by distinguishing the two cases, so just add the delta back even though the delta is 0. This would simply the code for the following patches too. Signed-off-by: Yang Shi --- mm/vmscan.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index 7b4e31eac2cf..7d6186a07daf 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c @@ -528,14 +528,10 @@ static unsigned long do_shrink_slab(struct shrink_control *shrinkctl, next_deferred = 0; /* * move the unused scan count back into the shrinker in a - * manner that handles concurrent updates. If we exhausted the - * scan, there is no need to do an update. + * manner that handles concurrent updates. */ - if (next_deferred > 0) - new_nr = atomic_long_add_return(next_deferred, - &shrinker->nr_deferred[nid]); - else - new_nr = atomic_long_read(&shrinker->nr_deferred[nid]); + new_nr = atomic_long_add_return(next_deferred, + &shrinker->nr_deferred[nid]); trace_mm_shrink_slab_end(shrinker, nid, freed, nr, new_nr, total_scan); return freed;