Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1316037ybk; Thu, 21 May 2020 04:02:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxosMXzQ3GoQBsN9V4bDhogKPT/JYO9iDK5rWWivZiXmUCVfk/0Zwg8m3UsIrYSiKjDQAnp X-Received: by 2002:a17:906:a843:: with SMTP id dx3mr2770329ejb.396.1590058952798; Thu, 21 May 2020 04:02:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590058952; cv=none; d=google.com; s=arc-20160816; b=AYb8jy4m0zOkMDiHP94Mn5Fv2nkfTt4QTMsDMUh8ggsk7IlnNv5I8AtP3e83co+M67 OcLZEOtHBojal/yrIj4pPLgsFbAU/8lfjhHAWMYbzYwTocX+Idr1BeA2NYPOOzNY/+/Y Wx605pzqFQzwfukYOWIPiypMEwNOZUgV4FFzK+3hxoAWPItELdDioZ5HBgICorRFV2cu ynH16t9//BeVJjx324giNbOYt7hRlRE0YTsOglq4Vos69kYf5sQCPfl7RypQW7JEENOB KC8gg1heXmO6vCYx4Wj7/1E3gv4wtI7+OoRq4Oxwm81fcqE8otu3wwsxHkJX80xJRpGP GUKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CZmUG7dBgwdfcd4tZquEzQk9e0BjnN8HVH0P/AP0xAQ=; b=gB9bh+nvAhv8AgW+clYQh0RU1KzGjJMOzcQCK7uopl0zmdokem+Yh2DvU54RuC4OK1 PRhq3WwZWZe8sKK3G/XmYVSIxqmJyhZm53RmL6zUJfMoMPH+ebNQmb3b0x4MFHQWuLlh acFNhuiII80B7iP5vdaEYEn5Nr1mWyHs32WnPJ4O1KmlLW5oMEifCImIDzlcfkW2YxTp hfsoa2n6QiGVftKvWYCFL+TCvWCSTkziTW5BFuadFk9B98mDbyhWsTUMlyxnAXMiti/a z7ctUMDrnykSNTqX8dBY2zQwFHO2XZtDagi14sY4UsdRG+ERa3hPVa/kEOkszIwBm/R0 BUOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b="0RXKPPF/"; 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 os22si2912157ejb.620.2020.05.21.04.02.08; Thu, 21 May 2020 04:02:32 -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="0RXKPPF/"; 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 S1728491AbgEULAi (ORCPT + 99 others); Thu, 21 May 2020 07:00:38 -0400 Received: from merlin.infradead.org ([205.233.59.134]:38906 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727864AbgEULAg (ORCPT ); Thu, 21 May 2020 07:00:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=CZmUG7dBgwdfcd4tZquEzQk9e0BjnN8HVH0P/AP0xAQ=; b=0RXKPPF/qH45a9Uvz0d9Q0bWKZ 0WAtXxt0m6432jYuZzuOwbeqGBH64mVBlpJFaCu0G0uFDelyIMjRL9RFXmEA7+GnBfUT/RRDarl3v YYh3Fd5GXjj/yvu/a6FSnpiqX0z35LmskqH9KArF+CnRtfhcfteIqBpwAL/Ly992IflTg4gC6pQcW dAYLa/EiLlPpqqgX+Hue6ulRPO+e0XYPG5Jl2JT4u1G8PFS3keKvJvhDGlxHNfXOv8kP4FDnuzw60 v/K6OZKOtWrizC1RNu3IoeBvYNMoDyfUj5IW1oyzUeNqmMsbVA9MFZKN3JbScS/WTNhaDpSIwcnk4 ZgK8AveA==; 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 1jbiw8-0002or-Ld; Thu, 21 May 2020 11:00:28 +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 74EAC3011C6; Thu, 21 May 2020 13:00:27 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 59E96212820EE; Thu, 21 May 2020 13:00:27 +0200 (CEST) Date: Thu, 21 May 2020 13:00:27 +0200 From: Peter Zijlstra To: Frederic Weisbecker Cc: Qian Cai , "Paul E. McKenney" , Linux Kernel Mailing List , Thomas Gleixner , Michael Ellerman , linuxppc-dev , Borislav Petkov Subject: Re: Endless soft-lockups for compiling workload since next-20200519 Message-ID: <20200521110027.GC325303@hirez.programming.kicks-ass.net> References: <20200520125056.GC325280@hirez.programming.kicks-ass.net> <20200521004035.GA15455@lenoir> <20200521093938.GG325280@hirez.programming.kicks-ass.net> <20200521104937.GB325303@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200521104937.GB325303@hirez.programming.kicks-ass.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 21, 2020 at 12:49:37PM +0200, Peter Zijlstra wrote: > On Thu, May 21, 2020 at 11:39:39AM +0200, Peter Zijlstra wrote: > > On Thu, May 21, 2020 at 02:40:36AM +0200, Frederic Weisbecker wrote: > > > This: > > > > > smp_call_function_single_async() { smp_call_function_single_async() { > > > // verified csd->flags != CSD_LOCK // verified csd->flags != CSD_LOCK > > > csd->flags = CSD_LOCK csd->flags = CSD_LOCK > > > > concurrent smp_call_function_single_async() using the same csd is what > > I'm looking at as well. > > So something like this ought to cure the fundamental problem and make > smp_call_function_single_async() more user friendly, but also more > expensive. > > The problem is that while the ILB case is easy to fix, I can't seem to > find an equally nice solution for the ttwu_remote_queue() case; that > would basically require sticking the wake_csd in task_struct, I'll also > post that. > > So it's either this: Or this: --- include/linux/sched.h | 4 ++++ kernel/sched/core.c | 7 ++++--- kernel/sched/fair.c | 2 +- kernel/sched/sched.h | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/linux/sched.h b/include/linux/sched.h index f38d62c4632c..136ee400b568 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -696,6 +696,10 @@ struct task_struct { struct uclamp_se uclamp[UCLAMP_CNT]; #endif +#ifdef CONFIG_SMP + call_single_data_t wake_csd; +#endif + #ifdef CONFIG_PREEMPT_NOTIFIERS /* List of struct preempt_notifier: */ struct hlist_head preempt_notifiers; diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 5b286469e26e..a7129652e89b 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -2320,7 +2320,7 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu, int wake_flags) if (llist_add(&p->wake_entry, &rq->wake_list)) { if (!set_nr_if_polling(rq->idle)) - smp_call_function_single_async(cpu, &rq->wake_csd); + smp_call_function_single_async(cpu, &p->wake_csd); else trace_sched_wake_idle_without_ipi(cpu); } @@ -2921,6 +2921,9 @@ int sched_fork(unsigned long clone_flags, struct task_struct *p) #endif #if defined(CONFIG_SMP) p->on_cpu = 0; + p->wake_csd = (struct __call_single_data) { + .func = wake_csd_func, + }; #endif init_task_preempt_count(p); #ifdef CONFIG_SMP @@ -6723,8 +6726,6 @@ void __init sched_init(void) rq->avg_idle = 2*sysctl_sched_migration_cost; rq->max_idle_balance_cost = sysctl_sched_migration_cost; - rq_csd_init(rq, &rq->wake_csd, wake_csd_func); - INIT_LIST_HEAD(&rq->cfs_tasks); rq_attach_root(rq, &def_root_domain); diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index 01f94cf52783..b6d8a7b991f0 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -10033,7 +10033,7 @@ static void kick_ilb(unsigned int flags) * is idle. And the softirq performing nohz idle load balance * will be run before returning from the IPI. */ - smp_call_function_single_async(ilb_cpu, &cpu_rq(ilb_cpu)->nohz_csd); + smp_call_function_single_async(ilb_cpu, &this_rq()->nohz_csd); } /* diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h index f7ab6334e992..c35f0ef43ab0 100644 --- a/kernel/sched/sched.h +++ b/kernel/sched/sched.h @@ -1021,7 +1021,6 @@ struct rq { #endif #ifdef CONFIG_SMP - call_single_data_t wake_csd; struct llist_head wake_list; #endif