From patchwork Tue Sep 21 16:13:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Saenz Julienne X-Patchwork-Id: 12508153 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=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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 BF1E9C433FE for ; Tue, 21 Sep 2021 16:13:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 311D7611BD for ; Tue, 21 Sep 2021 16:13:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 311D7611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7427A6B0075; Tue, 21 Sep 2021 12:13:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F2886B0078; Tue, 21 Sep 2021 12:13:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 593A4940007; Tue, 21 Sep 2021 12:13:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0006.hostedemail.com [216.40.44.6]) by kanga.kvack.org (Postfix) with ESMTP id 4A27A6B0075 for ; Tue, 21 Sep 2021 12:13:38 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0662B8249980 for ; Tue, 21 Sep 2021 16:13:38 +0000 (UTC) X-FDA: 78612076116.11.E23F116 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by imf08.hostedemail.com (Postfix) with ESMTP id 9D3BA30000AF for ; Tue, 21 Sep 2021 16:13:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632240817; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vXWudoCYk+miAPRPv+924oKRNUMxKATIYtsekauJQeA=; b=ZL3W5rI25QFGxvUzsLLO1XlsKrUxalKP7rsfK1ayCn0ayjE4SB4H/OqoZjIXZFMh9tiaOB Wwm3f0l/gO/5hX6SA9r0Y+7MVSe3QkPiDy05LhN7RRR/WUK4PMx9LL4OHd8tlth9zEr+n/ auidJD7BXIoZI3hIifW25C7GKR3wJ+I= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-263-wns3EzUZPWi6DNy9wCs69Q-1; Tue, 21 Sep 2021 12:13:35 -0400 X-MC-Unique: wns3EzUZPWi6DNy9wCs69Q-1 Received: by mail-wr1-f71.google.com with SMTP id e1-20020adfa741000000b0015e424fdd01so8809631wrd.11 for ; Tue, 21 Sep 2021 09:13:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vXWudoCYk+miAPRPv+924oKRNUMxKATIYtsekauJQeA=; b=ukXLa/abhVoiJK3A1KUzP2Zqs24eN1LCoiKHRoWkh+mfWBe5rnJmg4KEQpeGefPXkr yWjqjXIImloxidBa2FcySDFl5p50dmlmkeLeV7LRudbalMHlZQUPq0i1uuFdgYZ4FvJF pkjUjYR5vaHXHFYQXzBTUbKOYJA1iUdBTHlwLRkLjrIAdLihy9RdmxY/D0NjTdA2hEiM rmQMu66I48tw7negin1mjL9WqyHUlHYpLGfgEJT7s25bnrE9q4eDQAJBza6zYr0c3+C5 8vYKMCzeNgRm2CTOVtRw4ty5pLw97k8cfDt/C0baPCxvoaQ8hEAH9BsqbSuQmMig+Qi8 5eGg== X-Gm-Message-State: AOAM532quOkhO+s+XjpMA2l0m0qAIId6N3EGucLPEHktKFR7Xnnk93nO Ul5Z8oJUgwtFVuSAewll7V9i/sXvbMOG2XkTGXvkFNUaC6dHuJd477ZKqRtvgsrB0MXu1aftvuj HXPbjyJZtEJ0= X-Received: by 2002:a05:600c:ac5:: with SMTP id c5mr5643291wmr.191.1632240814683; Tue, 21 Sep 2021 09:13:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy02a6TNjxvk76ZUdxL9bhj9bDessU6ld3p2HrKam7H2usXY6Tt6rrZgJ6GdFwngIshxJ2HPw== X-Received: by 2002:a05:600c:ac5:: with SMTP id c5mr5643253wmr.191.1632240814460; Tue, 21 Sep 2021 09:13:34 -0700 (PDT) Received: from vian.redhat.com ([2a0c:5a80:1d03:b900:c3d1:5974:ce92:3123]) by smtp.gmail.com with ESMTPSA id t1sm19786477wrz.39.2021.09.21.09.13.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 09:13:34 -0700 (PDT) From: Nicolas Saenz Julienne To: akpm@linux-foundation.org, frederic@kernel.org Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, tglx@linutronix.de, cl@linux.com, peterz@infradead.org, juri.lelli@redhat.com, mingo@redhat.com, mtosatti@redhat.com, nilal@redhat.com, mgorman@suse.de, ppandit@redhat.com, williams@redhat.com, bigeasy@linutronix.de, anna-maria@linutronix.de, linux-rt-users@vger.kernel.org, Nicolas Saenz Julienne Subject: [PATCH 1/6] mm/swap: Introduce lru_cpu_needs_drain() Date: Tue, 21 Sep 2021 18:13:19 +0200 Message-Id: <20210921161323.607817-2-nsaenzju@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210921161323.607817-1-nsaenzju@redhat.com> References: <20210921161323.607817-1-nsaenzju@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZL3W5rI2; spf=none (imf08.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 216.205.24.124) smtp.mailfrom=nsaenzju@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 9D3BA30000AF X-Stat-Signature: phr1hs3k6corkke8t3esbkwf4oh31gwz X-HE-Tag: 1632240817-451366 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000208, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Upcoming patches will need to check whether a CPU needs to drain its LRU pagevecs on multiple locations. So move the check into its own function. Signed-off-by: Nicolas Saenz Julienne --- mm/swap.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mm/swap.c b/mm/swap.c index 04b678342c02..e7f9e4018ccf 100644 --- a/mm/swap.c +++ b/mm/swap.c @@ -726,6 +726,17 @@ static void lru_add_drain_per_cpu(struct work_struct *dummy) lru_add_drain(); } +static bool lru_cpu_needs_drain(int cpu) +{ + return pagevec_count(&per_cpu(lru_pvecs.lru_add, cpu)) || + data_race(pagevec_count(&per_cpu(lru_rotate.pvec, cpu))) || + pagevec_count(&per_cpu(lru_pvecs.lru_deactivate_file, cpu)) || + pagevec_count(&per_cpu(lru_pvecs.lru_deactivate, cpu)) || + pagevec_count(&per_cpu(lru_pvecs.lru_lazyfree, cpu)) || + need_activate_page_drain(cpu) || + has_bh_in_lru(cpu, NULL); +} + /* * Doesn't need any cpu hotplug locking because we do rely on per-cpu * kworkers being shut down before our page_alloc_cpu_dead callback is @@ -808,14 +819,7 @@ inline void __lru_add_drain_all(bool force_all_cpus) for_each_online_cpu(cpu) { struct work_struct *work = &per_cpu(lru_add_drain_work, cpu); - if (force_all_cpus || - pagevec_count(&per_cpu(lru_pvecs.lru_add, cpu)) || - data_race(pagevec_count(&per_cpu(lru_rotate.pvec, cpu))) || - pagevec_count(&per_cpu(lru_pvecs.lru_deactivate_file, cpu)) || - pagevec_count(&per_cpu(lru_pvecs.lru_deactivate, cpu)) || - pagevec_count(&per_cpu(lru_pvecs.lru_lazyfree, cpu)) || - need_activate_page_drain(cpu) || - has_bh_in_lru(cpu, NULL)) { + if (force_all_cpus || lru_cpu_needs_drain(cpu)) { INIT_WORK(work, lru_add_drain_per_cpu); queue_work_on(cpu, mm_percpu_wq, work); __cpumask_set_cpu(cpu, &has_work);