Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp312760pxf; Thu, 11 Mar 2021 04:39:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2samDnk9PKB4CWpAi/P4ZAAZHxj4ql5CGdnZFrnW5+aGNcOWd9aE8/XJZKuVa757l4bD3 X-Received: by 2002:aa7:c9d1:: with SMTP id i17mr8097425edt.46.1615466392201; Thu, 11 Mar 2021 04:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615466392; cv=none; d=google.com; s=arc-20160816; b=kEQ5wFjHSKg5yh3oYCx5+nBrLGOodexAiipKa6UEaZ37AZ+PhoWP61MmYEB13dQ6EB lD/9IDlKE5/WRL3/EE8KmzUv0UmyHx2A9qu7wPKR/GcOxIDbASw9ycEdItPsUjpmsqSN KYBIPa1DdUelDUFdKkoApVMFuOK5gfmv2p6GzV7lko/V9knRyycuCQqc990CER5bhiUb e8cyjZuUlgvBqMgT435a0SFjfRWF/HLZRXfYwOLYIW0P6OADiTWey92rZw7p832tCOMJ IQ7ATddFu8CbRtxX4UaLC6HEi49Z8c3S0+49rLSlEhErrfTpWBl/+7acvFmcGOo6RY32 F63A== 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=/TQc7/NE7lPYYTEG2yq05NGYZ4L9iiuA1lYayL9M3nE=; b=ZrOlGH4TsRK4QeeV5W4k1mC/8pIpGd/Crc4EYUym75mvsX0cfdUpwEnWtN2ponj70A 3QfhxLmpQGhFsTpXpLQ70RlhSL+j7wkW1F3yZsaN/cH/d9Jrfh3Fs1wK+79PyN6A1KUM Xmf2FD/EKxlTS/YslVMLXUb2vl8CToMsddMlXz57cGHDpsxm58hKQICjor8YdsOedSfx Ei0ZFwtOryKc9aL69aYjDI7u/ZP+8raNegluJqbt1568sUCUffTXbXOXk4HFpyd8wham UKsM2+6FjfMTTopIfMDKefmWQW/plKxiFYgTjUMtl0FoKp1PRmHpXKvVwKVz3eOcvg2o zRCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WFPislG3; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j5si1744634edh.218.2021.03.11.04.39.29; Thu, 11 Mar 2021 04:39:52 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=WFPislG3; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233398AbhCKMiI (ORCPT + 99 others); Thu, 11 Mar 2021 07:38:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:59978 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233362AbhCKMhk (ORCPT ); Thu, 11 Mar 2021 07:37:40 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 538A164F8E; Thu, 11 Mar 2021 12:37:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1615466259; bh=YhT4ZfDfikximjWV+HMU1tA5rnHSe7venEiAncjtcTU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WFPislG3zw00Fxk1C6+UQQy0SiTC2R1xeI1I4upL1Vut6jSdB4hPLcZna7sIeh0T2 eMlSIb/0lAEiyFdp/NjNeDWhvMcmzyuPhFCra6dsS7STGNtOCuk6Fcx+6+4P0udZ69 yNfN45adVTzZNBa1mpBbNEksRBzlOtqf53d6vCeWtHIgzdyV3dqGjMLkuIi82HmBBt rgaaSTG1OJxw2jMRjuGujZlTsBCFcnp2m0Av6Cd2MRwD6fGLo4bJQexIf2wrldpw/O Z+LSmvYKv5HB2tyc44jYAjMFfkO+V7Zkf2VZj6I1PWdjq/thfcF6KU/s9D15dFrIcE 5S4EIZGqDzAWA== From: Frederic Weisbecker To: Peter Zijlstra , Thomas Gleixner Cc: LKML , Marcelo Tosatti , "Rafael J . Wysocki" , Ti Zhou , Yunfeng Ye , Frederic Weisbecker , "Paul E . McKenney" , Ingo Molnar Subject: [PATCH 09/10] tick/nohz: Change signal tick dependency to wakeup CPUs of member tasks Date: Thu, 11 Mar 2021 13:37:07 +0100 Message-Id: <20210311123708.23501-10-frederic@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210311123708.23501-1-frederic@kernel.org> References: <20210311123708.23501-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marcelo Tosatti Rather than waking up all nohz_full CPUs on the system, only wakeup the target CPUs of member threads of the signal. Reduces interruptions to nohz_full CPUs. Signed-off-by: Marcelo Tosatti Cc: Yunfeng Ye Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: Rafael J. Wysocki Signed-off-by: Frederic Weisbecker --- include/linux/tick.h | 8 ++++---- kernel/time/posix-cpu-timers.c | 4 ++-- kernel/time/tick-sched.c | 15 +++++++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/include/linux/tick.h b/include/linux/tick.h index bfc96cbe955c..9e71ab1889aa 100644 --- a/include/linux/tick.h +++ b/include/linux/tick.h @@ -215,7 +215,7 @@ extern void tick_nohz_dep_set_task(struct task_struct *tsk, enum tick_dep_bits bit); extern void tick_nohz_dep_clear_task(struct task_struct *tsk, enum tick_dep_bits bit); -extern void tick_nohz_dep_set_signal(struct signal_struct *signal, +extern void tick_nohz_dep_set_signal(struct task_struct *tsk, enum tick_dep_bits bit); extern void tick_nohz_dep_clear_signal(struct signal_struct *signal, enum tick_dep_bits bit); @@ -260,11 +260,11 @@ static inline void tick_dep_clear_task(struct task_struct *tsk, if (tick_nohz_full_enabled()) tick_nohz_dep_clear_task(tsk, bit); } -static inline void tick_dep_set_signal(struct signal_struct *signal, +static inline void tick_dep_set_signal(struct task_struct *tsk, enum tick_dep_bits bit) { if (tick_nohz_full_enabled()) - tick_nohz_dep_set_signal(signal, bit); + tick_nohz_dep_set_signal(tsk, bit); } static inline void tick_dep_clear_signal(struct signal_struct *signal, enum tick_dep_bits bit) @@ -293,7 +293,7 @@ static inline void tick_dep_set_task(struct task_struct *tsk, enum tick_dep_bits bit) { } static inline void tick_dep_clear_task(struct task_struct *tsk, enum tick_dep_bits bit) { } -static inline void tick_dep_set_signal(struct signal_struct *signal, +static inline void tick_dep_set_signal(struct task_struct *tsk, enum tick_dep_bits bit) { } static inline void tick_dep_clear_signal(struct signal_struct *signal, enum tick_dep_bits bit) { } diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c index a71758e34e45..932e0cb4b57b 100644 --- a/kernel/time/posix-cpu-timers.c +++ b/kernel/time/posix-cpu-timers.c @@ -523,7 +523,7 @@ static void arm_timer(struct k_itimer *timer, struct task_struct *p) if (CPUCLOCK_PERTHREAD(timer->it_clock)) tick_dep_set_task(p, TICK_DEP_BIT_POSIX_TIMER); else - tick_dep_set_signal(p->signal, TICK_DEP_BIT_POSIX_TIMER); + tick_dep_set_signal(p, TICK_DEP_BIT_POSIX_TIMER); } /* @@ -1358,7 +1358,7 @@ void set_process_cpu_timer(struct task_struct *tsk, unsigned int clkid, if (*newval < *nextevt) *nextevt = *newval; - tick_dep_set_signal(tsk->signal, TICK_DEP_BIT_POSIX_TIMER); + tick_dep_set_signal(tsk, TICK_DEP_BIT_POSIX_TIMER); } static int do_cpu_nanosleep(const clockid_t which_clock, int flags, diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 8457f15a5073..a866fd8e7bb5 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -444,9 +444,20 @@ EXPORT_SYMBOL_GPL(tick_nohz_dep_clear_task); * Set a per-taskgroup tick dependency. Posix CPU timers need this in order to elapse * per process timers. */ -void tick_nohz_dep_set_signal(struct signal_struct *sig, enum tick_dep_bits bit) +void tick_nohz_dep_set_signal(struct task_struct *tsk, + enum tick_dep_bits bit) { - tick_nohz_dep_set_all(&sig->tick_dep_mask, bit); + int prev; + struct signal_struct *sig = tsk->signal; + + prev = atomic_fetch_or(BIT(bit), &sig->tick_dep_mask); + if (!prev) { + struct task_struct *t; + + lockdep_assert_held(&tsk->sighand->siglock); + __for_each_thread(sig, t) + tick_nohz_kick_task(t); + } } void tick_nohz_dep_clear_signal(struct signal_struct *sig, enum tick_dep_bits bit) -- 2.25.1