Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp8755ybm; Tue, 26 May 2020 09:27:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVOjIBqpKqvv1luOjr72HmBnTh0Qd6qEu39knm9ycBALU0iT5NUsQpJhmCrgA3FcQoUEMI X-Received: by 2002:a17:906:c01:: with SMTP id s1mr1894808ejf.370.1590510426115; Tue, 26 May 2020 09:27:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590510426; cv=none; d=google.com; s=arc-20160816; b=h4/vKYAixSEIFoH6iSTzQfUQN83SupWoiK4PXT/eIw73eNACj4JiYmOLaJxk5EmG9f bg8vNe6FbYWcpigD/qH8DE8a9OcONeIpr1g4X7ShH7SD6N+dmfu67gz73KwHGvYsEKA5 voHCePhkkTu95V77a2I9HJhCJ7MSFCe0OxuXX24l7SRBOyDeHg4NWu8zrEH1tp7trgda cc2kf+Knlkz9Tn+wGK0YEOcU0VjrAlFORSJK7Uja2Rsb47n9ggcfvzChmHf5ekkQobsv +Wo+7YwiTTlft7Roq9uPF3U7D0wRoxcfydwu7BhavM+702YBcfGdUs6qgA2wnerYMQ94 OuRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:subject:cc:to :from:date:user-agent:message-id:dkim-signature; bh=Kdhc7G0MOHSHyTSs18tW/2Sp/VNPCGM39F2FG5g0xA0=; b=nYk38RTpToUOkCseoGZSI7M0JGoR1VlsyFv0ieOmFTXwo3ioAFlFicBCXwL02BlUQn V1wpQu1hp0ZRBYqYe6GEKqM19XfqkgEkzZ7xIE7zxqIlvGMaSq20xK1b6jfAQrx41BYD 2JgZM69yI9V0o2odXEvX8m0gcJcwaIOI1sk2FUXc6qTmML0QsY66sCe5Q59DdJXQjOTp 9lgkUKCilynuUEMZxFDPil7M2z0pewhNnKQqY4uMW9c2HT9rivB6xsX1fcWqLuqCdaaW xDIdWZ3UjupIBNl/a1DTO7B1DT87VWR2Ny8y48JtfS0lBPLOdQRnFTYydcGOnp7f0VwS 54rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=fMkz3cuy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m1si167665ejk.303.2020.05.26.09.26.38; Tue, 26 May 2020 09:27:06 -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=fail header.i=@infradead.org header.s=merlin.20170209 header.b=fMkz3cuy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388672AbgEZQY2 (ORCPT + 99 others); Tue, 26 May 2020 12:24:28 -0400 Received: from merlin.infradead.org ([205.233.59.134]:35178 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728450AbgEZQYZ (ORCPT ); Tue, 26 May 2020 12:24:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=Content-Type:MIME-Version:References: Subject:Cc:To:From:Date:Message-ID:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:In-Reply-To; bh=Kdhc7G0MOHSHyTSs18tW/2Sp/VNPCGM39F2FG5g0xA0=; b=fMkz3cuyOKIigiaOFaLhqZGDoc yuG4u+ptyI23uLEzyZQYTdoNve9a/ohhhnF3SGysE8oOYoQmTiy45J++y05Sy+YRXtK2dG4DJfr7A VZZ72S6aevWhlSdR/o8Uha0DNmbX/ylhhmNP+5sY4Cd6qRzzxyGJgr/3FTSa8sbIcxM8roujI6FnT t/Iq5yNJYuMrz3j6QW5l5Fhf/1gzvJ9KW0NeWzBRCdbZ5uKA7dwA45tm5448WrvcA2zncOJBO4pC/ 1VXPu9rTYwUN+MGSNZmj6U1AtFSpCmVcgslboaIxOvOPqkpNR6BaruXhvp+8NhdfcBHD2rB9dbQmn eAUy2XDA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1jdcIv-0005Tf-8K; Tue, 26 May 2020 16:19:49 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 72A8E3062EA; Tue, 26 May 2020 18:19:41 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 0) id 55EE320FF793C; Tue, 26 May 2020 18:19:41 +0200 (CEST) Message-ID: <20200526161907.953304789@infradead.org> User-Agent: quilt/0.66 Date: Tue, 26 May 2020 18:11:01 +0200 From: Peter Zijlstra To: tglx@linutronix.de, frederic@kernel.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, cai@lca.pw, mgorman@techsingularity.net, peterz@infradead.org Subject: [RFC][PATCH 4/7] smp: Optimize send_call_function_single_ipi() References: <20200526161057.531933155@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Just like the ttwu_queue_remote() IPI, make use of _TIF_POLLING_NRFLAG to avoid sending IPIs to idle CPUs. Signed-off-by: Peter Zijlstra (Intel) --- kernel/sched/core.c | 10 ++++++++++ kernel/sched/idle.c | 1 + kernel/sched/sched.h | 2 ++ kernel/smp.c | 16 +++++++++++++++- 4 files changed, 28 insertions(+), 1 deletion(-) --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2296,6 +2296,16 @@ static void wake_csd_func(void *info) sched_ttwu_pending(); } +void send_call_function_single_ipi(int cpu) +{ + struct rq *rq = cpu_rq(cpu); + + if (!set_nr_if_polling(rq->idle)) + arch_send_call_function_single_ipi(cpu); + else + trace_sched_wake_idle_without_ipi(cpu); +} + /* * Queue a task on the target CPUs wake_list and wake the CPU via IPI if * necessary. The wakee CPU on receipt of the IPI will queue the task --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -289,6 +289,7 @@ static void do_idle(void) */ smp_mb__after_atomic(); + flush_smp_call_function_from_idle(); sched_ttwu_pending(); schedule_idle(); --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1506,6 +1506,8 @@ static inline void unregister_sched_doma } #endif +extern void flush_smp_call_function_from_idle(void); + #else static inline void sched_ttwu_pending(void) { } --- a/kernel/smp.c +++ b/kernel/smp.c @@ -135,6 +135,8 @@ static __always_inline void csd_unlock(c static DEFINE_PER_CPU_SHARED_ALIGNED(call_single_data_t, csd_data); +extern void send_call_function_single_ipi(int cpu); + /* * Insert a previously allocated call_single_data_t element * for execution on the given CPU. data must already have @@ -178,7 +180,7 @@ static int generic_exec_single(int cpu, * equipped to do the right thing... */ if (llist_add(&csd->llist, &per_cpu(call_single_queue, cpu))) - arch_send_call_function_single_ipi(cpu); + send_call_function_single_ipi(cpu); return 0; } @@ -278,6 +280,18 @@ static void flush_smp_call_function_queu } } +void flush_smp_call_function_from_idle(void) +{ + unsigned long flags; + + if (llist_empty(this_cpu_ptr(&call_single_queue))) + return; + + local_irq_save(flags); + flush_smp_call_function_queue(true); + local_irq_restore(flags); +} + /* * smp_call_function_single - Run a function on a specific CPU * @func: The function to run. This must be fast and non-blocking.