Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2865239pxb; Tue, 21 Sep 2021 09:17:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvheORHJgvDs+urO9rTs/tJUZmrHnrA89ktwbZoEW77mF9sh/OmpShr2n5OHSeYbHpm9uA X-Received: by 2002:a17:906:f906:: with SMTP id lc6mr34738502ejb.487.1632241037885; Tue, 21 Sep 2021 09:17:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632241037; cv=none; d=google.com; s=arc-20160816; b=0r3JSgOgZXKYMqib3ZjXeQBODTvpc8uPf8cdz2xAMHiAZeZbAQN3UCJhVUUFa+1kVR wyzF8ou4CdfxuopwzWF/YkD2or9xPIa+CU1l6C5wyYckd0lOY9mn2xzGwFiggWUwkYeP jPAubg5ZIFBUU7ER0VedQsAvMqwq2rl2rBiT9pVeP+TSNhr9NXncJg+9J2bUGdywNVFH ObxIwBbt17Y4M6Ta9MMsUSl1CkNQCCx7RV5pZFFOzNAXn3k0jtB/gaV9MLM98TK4XTQ6 JWjkieslAPAzbumLqxKx8aLTiovMilqm2WtKGE32dg4U40Ha/kG1L46Y3L0DlIXTaZNZ eCDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kD1gPXuN5hXdBx7xkUXEssekkfNTX/T0+M6z2qHPbrk=; b=p1+iuU9oKmSPxnEkHG7Jtdhr70Fum55qfemhGSnQAYv3DoN/P3r+TgkpQE4geZAQ7k 9MA4yia54PJCP3qqYZUuTIBipxg6z6OLrzIR0RMb7z3cYiTlNAMuBfKoyhWA1hikrgq1 MelerxLCbbU2pZtNqkDrQPuML65VXgQrtMwxzYHyA/Aia+EWbRS53FXJP9vliAfAlkIj 2JL1iwTH8KrIgvepEeKZ+bdARuTJsqjAxrP2UptXg+MZWVexi6mQrr770dRKfMfd+WQ9 DLRwQmOr/6plqbe+vBC7tmPsHKDWLhvuvyXXQ3Iiwq2PmgVDuWMdK9OM3hXzAWVi689s fDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZcaTELKY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j19si4020508edq.322.2021.09.21.09.16.50; Tue, 21 Sep 2021 09:17:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZcaTELKY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234361AbhIUQPU (ORCPT + 99 others); Tue, 21 Sep 2021 12:15:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46445 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234339AbhIUQPM (ORCPT ); Tue, 21 Sep 2021 12:15:12 -0400 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kD1gPXuN5hXdBx7xkUXEssekkfNTX/T0+M6z2qHPbrk=; b=ZcaTELKY6aRxsKo85WXgIGFAi4WyRxFd4GZWNO4y1TWZxk+lUnUgYt0clo5OF0b43PzjnT udQUO8nT1w4XTB8oJdacBqwu7cMHwKZ9CYx7l5SkXW2lmIrhO3XpdWM1InbWMPCVGyOdlL gXiFDkoMumcx7CVmBnEGGMlIsTeesHE= 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-168-ZANv-Ws5OwmfVZb9gNtysg-1; Tue, 21 Sep 2021 12:13:41 -0400 X-MC-Unique: ZANv-Ws5OwmfVZb9gNtysg-1 Received: by mail-wr1-f69.google.com with SMTP id x2-20020a5d54c2000000b0015dfd2b4e34so9253456wrv.6 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=pQD4FUZbl6usfAxazTFVJDlwSMGovAqwfiiWUU2xwVJniP0vMGGSBpw+pbOp/lhqdq fBDe4c0rJH+VeXTb4DIBMlapCLWtZver93OnmKJ7Lb96JSOx+B5GO9ZryXM/b4ioMFsp wVoTqokakQ9kFsNHEe2saJV/LXxc0YTe/G/lRCPRZDlya/qb9pEOGsFG60/v4mIfveqU BAvclk7NG9/XMp+aPQyfBeaHuwKGi0XXaz2KwGhoWJflQnYQLNVOm9LOJhUg8ALgLAIu nnKJ+k0tIdh56Wg311UWWHAPIcg7VJJOAGSu6x42aPb6TDorE20YZOe/YKgGPsbOiib9 vmgg== X-Gm-Message-State: AOAM533nvPzgXW/sRk8A3Y/BUCp5/Qt1r6+dkkMK8F8+evwAR1kh1GIB pEiYqO4Ik+LisUP8ZxR0peNXWmfK95Rs35FVaZY40bDH2Jvt2DNzo6EhjOxG5uDgHuHevmWKOBO YonLSKBnd0/f4sfsu4we+vUZq X-Received: by 2002:adf:f890:: with SMTP id u16mr35026733wrp.388.1632240819873; Tue, 21 Sep 2021 09:13:39 -0700 (PDT) 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); } -- 2.31.1