Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp5151649ybb; Tue, 24 Mar 2020 11:51:18 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuzvQoPS+ltwiurI7NevHfj4BUqn2SAwYHUVcGSfxwqS9gddTA60s2tF5TdwrXqiHeBVmVX X-Received: by 2002:aca:4fc7:: with SMTP id d190mr4523183oib.100.1585075878718; Tue, 24 Mar 2020 11:51:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585075878; cv=none; d=google.com; s=arc-20160816; b=du0hTxlCPPspSTjiHyJ36hjQVInepToImGH6RU0znvz0KBu+MC3a1tAZij3mqk37es GJ0dPriKOABcj9u9fgNdBA4rq7E6PricXkcALSwsYxkkBiZQFFBoH3XW7p4Gv+AKYnrl meQDNg/JCkyMBrA6Lyei4bhsS6b++mOVNKlkrY/2FFff1IdnT1VCef4yv/LpPXdn9ytJ 8bGQEZMfTeVlGN4Kf4gWc5UfJmD/+yo4Kc1mKk3VBX/u3Xx5L0UCq54mY/aCXYTW/YQI kv6NhFZqZQE+eSh/SeXLUY+iqBuA8ba9UmlMqkzRopOcWsNZrqDJKQbOQB+vKjpkBJKX WkwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xovp2IRENC1ieKOWc2uYOS9mTeP7hB0qq6rWQBQMySs=; b=jmw/at8yXaf/MvVm7zulj8y6An15D16X1uN+hyK0rh2tyx1xxutpTzttnTrhYetAoX vPYOBwdNe1HGM6vswtycgfCyCaS3ysdrw8U2bevljpyTRviFvk2GdUYxf/kRxUGmznw8 yrmiSHvbgtk6bQTVssvNZjppdr6DBpIq+NKD2VZWRJHw5WrgJWILexz1NPIjtBYVBV2/ JIqlGHYjdpGqM5XoGOEF1DSX96nzZrq4aYiQMb3eqwpU/dwdX0GvKVyAcWS4I5Ib5bAV sDm1l/BiFyXcXCqnvzD48VKQBxotAu+kje8xgzCN9CxVbKPblCve5S4J/jEBYm7eH69Z 834g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=SVvirGnr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15si4302950otk.63.2020.03.24.11.51.05; Tue, 24 Mar 2020 11:51:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=SVvirGnr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbgCXStu (ORCPT + 99 others); Tue, 24 Mar 2020 14:49:50 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:37230 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727468AbgCXStu (ORCPT ); Tue, 24 Mar 2020 14:49:50 -0400 Received: by mail-qk1-f193.google.com with SMTP id x3so8900760qki.4 for ; Tue, 24 Mar 2020 11:49:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=xovp2IRENC1ieKOWc2uYOS9mTeP7hB0qq6rWQBQMySs=; b=SVvirGnr/T0FjI3nqFgreHYMr6mc+UZL8Z+s+VddsQqi21EjHWPd+E+HSTEHFk4cE+ tHb3us5ZnYiZl+qpHxndAv8D0pKH1iTMQJtZvxCX0rigKt7V3DwIY+t8gVFSAsdkDTgE 64FiZOMvPnAt58rLWCUvaqgL3JxMYlnkEHzAg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=xovp2IRENC1ieKOWc2uYOS9mTeP7hB0qq6rWQBQMySs=; b=nO36qHAarpY5M2dDSzC5ZpSxXfLeTciUSm39h0mgVhMbYL1NSVDUeNvRoqgCqQez+3 4DVUUg5o/oBwwk2iLKV56IBq5QUsP0L4P0XOZzi6lWKUBawrkle9FXNSpxIGQmkPdUws zrnuelOcsxkNZotWwjmYalmMWMEPJkxVFKhRR3KsU1mqBrCUSB+8wI6YnEWwgXwPYXw+ o1KdwAFsN3Up/0TKpoy4N5F/t4hwzGWB3pPKzh/F/aFTg0Dkn1cERLa4dODuZkUQ3Ufe a/AU4UXQcyeswvqtn6DNFHHSr+O91IIVaFkpOTXVa3zRRPyAARWNNuFsK7rTiiKKWEIR 4/og== X-Gm-Message-State: ANhLgQ3PYQqvE3A+pUEmDTDPPXtZL9FkDBIPArkUkaAgbUeKyh0qH35P cDFseFx/H01ftXHagfx8Wzn6U3v/VSk= X-Received: by 2002:a37:49cc:: with SMTP id w195mr27682802qka.42.1585075787451; Tue, 24 Mar 2020 11:49:47 -0700 (PDT) Received: from localhost ([2620:15c:6:12:9c46:e0da:efbf:69cc]) by smtp.gmail.com with ESMTPSA id 4sm9693732qkl.51.2020.03.24.11.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Mar 2020 11:49:46 -0700 (PDT) Date: Tue, 24 Mar 2020 14:49:46 -0400 From: Joel Fernandes To: "Li, Aubrey" Cc: paulmck@kernel.org, linux-kernel@vger.kernel.org, vpillai , Aaron Lu , Aubrey Li , peterz@infradead.org, Ben Segall , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Mel Gorman , Steven Rostedt , Vincent Guittot Subject: Re: [PATCH] sched: Use RCU-sched in core-scheduling balancing logic Message-ID: <20200324184946.GD257597@google.com> References: <20200313232918.62303-1-joel@joelfernandes.org> <20200314003004.GI3199@paulmck-ThinkPad-P72> <20200323152126.GA141027@google.com> <6d933ce2-75e3-6469-4bb0-08ce9df29139@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6d933ce2-75e3-6469-4bb0-08ce9df29139@linux.intel.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 24, 2020 at 11:01:27AM +0800, Li, Aubrey wrote: > On 2020/3/23 23:21, Joel Fernandes wrote: > > On Mon, Mar 23, 2020 at 02:58:18PM +0800, Li, Aubrey wrote: > >> On 2020/3/14 8:30, Paul E. McKenney wrote: > >>> On Fri, Mar 13, 2020 at 07:29:18PM -0400, Joel Fernandes (Google) wrote: > >>>> rcu_read_unlock() can incur an infrequent deadlock in > >>>> sched_core_balance(). Fix this by using the RCU-sched flavor instead. > >>>> > >>>> This fixes the following spinlock recursion observed when testing the > >>>> core scheduling patches on PREEMPT=y kernel on ChromeOS: > >>>> > >>>> [ 14.998590] watchdog: BUG: soft lockup - CPU#0 stuck for 11s! [kworker/0:10:965] > >>>> > >>> > >>> The original could indeed deadlock, and this would avoid that deadlock. > >>> (The commit to solve this deadlock is sadly not yet in mainline.) > >>> > >>> Acked-by: Paul E. McKenney > >> > >> I saw this in dmesg with this patch, is it expected? > >> > >> [ 117.000905] ============================= > >> [ 117.000907] WARNING: suspicious RCU usage > >> [ 117.000911] 5.5.7+ #160 Not tainted > >> [ 117.000913] ----------------------------- > >> [ 117.000916] kernel/sched/core.c:4747 suspicious rcu_dereference_check() usage! > >> [ 117.000918] > >> other info that might help us debug this: > > > > Sigh, this is because for_each_domain() expects rcu_read_lock(). From an RCU > > PoV, the code is correct (warning doesn't cause any issue). > > > > To silence warning, we could replace the rcu_read_lock_sched() in my patch with: > > preempt_disable(); > > rcu_read_lock(); > > > > and replace the unlock with: > > > > rcu_read_unlock(); > > preempt_enable(); > > > > That should both take care of both the warning and the scheduler-related > > deadlock. Thoughts? > > > > How about this? > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > index a01df3e..7ff694e 100644 > --- a/kernel/sched/core.c > +++ b/kernel/sched/core.c > @@ -4743,7 +4743,6 @@ static void sched_core_balance(struct rq *rq) > int cpu = cpu_of(rq); > > rcu_read_lock(); > - raw_spin_unlock_irq(rq_lockp(rq)); > for_each_domain(cpu, sd) { > if (!(sd->flags & SD_LOAD_BALANCE)) > break; > @@ -4754,7 +4753,6 @@ static void sched_core_balance(struct rq *rq) > if (steal_cookie_task(cpu, sd)) > break; > } > - raw_spin_lock_irq(rq_lockp(rq)); try_steal_cookie() does a double_rq_lock(). Would this change not deadlock with that? thanks, - Joel