From patchwork Tue Sep 21 16:13:23 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: 12508161 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 935EBC433EF for ; Tue, 21 Sep 2021 16:13:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49D11610A1 for ; Tue, 21 Sep 2021 16:13:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 49D11610A1 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 8F2616B007E; Tue, 21 Sep 2021 12:13:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8A0AC940007; Tue, 21 Sep 2021 12:13:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 680E16B0081; Tue, 21 Sep 2021 12:13:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 549E66B007E for ; Tue, 21 Sep 2021 12:13:44 -0400 (EDT) Received: from smtpin23.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 130068249980 for ; Tue, 21 Sep 2021 16:13:44 +0000 (UTC) X-FDA: 78612076368.23.8E02354 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 9DB815000303 for ; Tue, 21 Sep 2021 16:13:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1632240822; 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=kD1gPXuN5hXdBx7xkUXEssekkfNTX/T0+M6z2qHPbrk=; b=FtYLoBdhRPXdwWtwAhmKFgYY3amkPQvmcOcD3NFQfcWnxxA4rg/cAqj7MnqXRji/mjp9R8 z7uj0yCb8qOv5ifBU0+FhhV8nyn+O440c7S3mGsZuInB1+MyCD4dQxkP5A+U07Mi7XXtGO hKd8EsQVLvxce4FkKpb9vrjUqoRwx6M= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-158-Uwt67j4mNwS8C_kS1-3E-g-1; Tue, 21 Sep 2021 12:13:41 -0400 X-MC-Unique: Uwt67j4mNwS8C_kS1-3E-g-1 Received: by mail-wr1-f69.google.com with SMTP id r9-20020a5d4989000000b0015d0fbb8823so9239938wrq.18 for ; Tue, 21 Sep 2021 09:13:40 -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=kD1gPXuN5hXdBx7xkUXEssekkfNTX/T0+M6z2qHPbrk=; b=SZPxc59OHJQlMeYM1XjMHVDybrlfMQCvtEP6eiXiDxWVSoyH5dnlCi3vXfJakrrzNp 4TvVkrnCCAIg1iLcK81mcRnSJm5MItuTjxgVvLMPJ6Ewto0P6+Czv97bsKS60JqL5Om+ tfJ4TPAUPVg+5SBaja0PqViA3gxXDSW6F9pSsYoYR6kJ9HsIRVp+0iiyKRCG6WmwV2lR 0CCty/X4Z4dRdT65/e8ycQxbL9li3evBnyX/6Vhj5sdxwUf+2DKfuoT+MmaCy0XyMO1U QTdCqplbgWYg/oz8P7sW5cIC22O4dxGlNltksOliCkvNgbQylpoLZgpSMWJNpAOqAZQE zKiA== X-Gm-Message-State: AOAM533Un66lH0wBtsiDL5zEwXB+3JmaUsIO5cQu3SkPtSJ2gZF+ewxy uOkIVCfs7txuT2yKGfc7gfPtU9IcPhk3T6gLaAK6RKmE2w/ShkaATn2dEnZ8o9rT8CiVdxP/lJg jGYA4cbVFDbs= X-Received: by 2002:adf:f890:: with SMTP id u16mr35026727wrp.388.1632240819873; Tue, 21 Sep 2021 09:13:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwILlB4+iYeakvY1cY1M2iraZrOJrl8W7MLtYotoTLsG/waIBsVBPTg6O9yF1Fb9VfMjynvqg== X-Received: by 2002:adf:f890:: with SMTP id u16mr35026696wrp.388.1632240819716; Tue, 21 Sep 2021 09:13:39 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Sep 2021 09:13:39 -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 5/6] mm/page_alloc: Allow remote per-cpu page list draining Date: Tue, 21 Sep 2021 18:13:23 +0200 Message-Id: <20210921161323.607817-6-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 X-Stat-Signature: ttq56mwf9n87t9yhjzj4hszyw8p6g976 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=FtYLoBdh; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf04.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=nsaenzju@redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9DB815000303 X-HE-Tag: 1632240822-907245 X-Bogosity: Ham, tests=bogofilter, spamicity=0.001047, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Some setups, notably NOHZ_FULL CPUs, are too busy to handle the per-cpu drain work queued by __drain_all_pages(). So introduce new a mechanism to remotely drain the per-cpu lists. It is made possible by using a more constraining locking scheme, which is disabled by default and can be enabled through the 'remote_pcpu_cache_access' static key. Regular users shouldn't see any functional or performance change. Upcoming patches will make use of the static key. This is based on previous work by Thomas Gleixner, Anna-Maria Gleixner, and Sebastian Andrzej Siewior[1]. [1] https://patchwork.kernel.org/project/linux-mm/patch/20190424111208.24459-3-bigeasy@linutronix.de/ Signed-off-by: Nicolas Saenz Julienne --- mm/page_alloc.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 3244eb2ab51b..717df675ea06 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3268,15 +3268,25 @@ static void __drain_all_pages(struct zone *zone, bool force_all_cpus) cpumask_clear_cpu(cpu, &cpus_with_pcps); } - for_each_cpu(cpu, &cpus_with_pcps) { - struct pcpu_drain *drain = per_cpu_ptr(&pcpu_drain, cpu); + if (static_branch_unlikely(&remote_pcpu_cache_access)) { + for_each_cpu(cpu, &cpus_with_pcps) { + if (zone) { + drain_pages_zone(cpu, zone); + } else { + drain_pages(cpu); + } + } + } else { + for_each_cpu(cpu, &cpus_with_pcps) { + struct pcpu_drain *drain = per_cpu_ptr(&pcpu_drain, cpu); - drain->zone = zone; - INIT_WORK(&drain->work, drain_local_pages_wq); - queue_work_on(cpu, mm_percpu_wq, &drain->work); + drain->zone = zone; + INIT_WORK(&drain->work, drain_local_pages_wq); + queue_work_on(cpu, mm_percpu_wq, &drain->work); + } + for_each_cpu(cpu, &cpus_with_pcps) + flush_work(&per_cpu_ptr(&pcpu_drain, cpu)->work); } - for_each_cpu(cpu, &cpus_with_pcps) - flush_work(&per_cpu_ptr(&pcpu_drain, cpu)->work); mutex_unlock(&pcpu_drain_mutex); }