Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1451264ybt; Thu, 2 Jul 2020 05:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUgUBuaX5Fw2fccsDYdvwG3pAiD8r/JM1pZ6qW6y2BhkcxQq+guhAeCdl1krFwfKYNzx4y X-Received: by 2002:a17:906:ca0e:: with SMTP id jt14mr26827496ejb.325.1593694738430; Thu, 02 Jul 2020 05:58:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593694738; cv=none; d=google.com; s=arc-20160816; b=a5Ac0q3jSq1iEbprWtPJvvd3JE7s4oEVMNdRC7RhLqAgSQdeUKF3tqF5o/LeuoYMj/ q58wLUiQspolAgd/sauQgzCtEbkzp2KtjbThkr9QprZlMyQy27612ACCnwvjRLG3k5oL RMuYAV6iE9Sofd9JRifQx+MGSroXWCXvTln9MjNvb/o75l+QQXSD5T22zZj4F3cQXdAS JQsxveMU/858QeecPP2I8uhR7Sr8lqig95899+AfZERcuEVKQCyJ5Ug226sVU/nica4J G1jI8PbGhoR8ZancwLUpQDtQrVOegr6If9UGeL4VX68Cc+TBabzKeTfOl8yZ5A4lFQT7 Gfmw== 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=9SWGnubDWqg/t2WsVA0LlntzVzjp9DweIcUd8FpWx0c=; b=ZWroGU7QVwSHH2NhNa/iPza17rfyJvXTgyoJf1JXf4aRj4tPDRzh6YXzcKo/DTBOU7 BqDGDt1B70U5EmnUKQ/fhWzFcee7Zps4mDOhKceDtfTxCPyibEr8YbgOo7DOWx9pyPIu xW0iOtuY9zNAdw0zPS+Jv82pVSD6nBxTYpKewwC/BCapviu0vZ24DbFUstv3r55OMPA5 OEzT3wHqlNb/5NrtlypoawVeAz2I5HezfQQb/AGL8Ocdc/rK8V0iPtKarRC1EanfFIUY V6SV/RXKbBeJfHNDsy3v5WIAhMdpmU7uI8EUIwUWOax0rbAZMXc3FkI86PyIKKoCJZBg afeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=HW4qqfzQ; 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 bm13si5603596edb.426.2020.07.02.05.58.35; Thu, 02 Jul 2020 05:58:58 -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=@joelfernandes.org header.s=google header.b=HW4qqfzQ; 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 S1729257AbgGBM6C (ORCPT + 99 others); Thu, 2 Jul 2020 08:58:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729218AbgGBM57 (ORCPT ); Thu, 2 Jul 2020 08:57:59 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CAECC08C5DC for ; Thu, 2 Jul 2020 05:57:59 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id m9so12603176qvx.5 for ; Thu, 02 Jul 2020 05:57:58 -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; bh=9SWGnubDWqg/t2WsVA0LlntzVzjp9DweIcUd8FpWx0c=; b=HW4qqfzQl3zi9IpbnSdop+NeCDE2cAIEPclDJQJa7yfeofwC955o1D5TwSgfCpzdys j8KL9SCqcXxqdttZOSNOsd9m2+MehTVTm4nHLlzNK8q0PoQws1QFDCjj3jDJNQ/pftsZ KEQ1SsOPVNXykmJZB5iWF5BSK+xEo7yDkUf8w= 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; bh=9SWGnubDWqg/t2WsVA0LlntzVzjp9DweIcUd8FpWx0c=; b=DlDh6+UE8nHjvNIUpHwFZcsu40IqkL04O+VHeZRlw25nl2lS5wW1fQH3jd+LQWBScM +e1WVgG3cICmnjbTXaB0WOilXsNC4nc0BPaJE0h3M8VMV78LtqnAktmyWKUwjVeIZ2PK MHs/vMBgkoQTls8JQDO/g01rPqpJjRdVzpQjMpxSDZ+dwk333zcOL49gvT99eAPcanFy VVrFd+Ubwds93mo/wAbWQeqDVC5RPhlIrAxdK6RvV2eaSi3/ufNrVmO4FZ44dFiodhQ8 pl1McLBdP7MoWbhIirDf0rYfgyoPAXNov6EiFpv+6NfgGk+6shW8yCfQ1ndrEDuYhp40 FdTQ== X-Gm-Message-State: AOAM530zeF7ikOhurs4XqlKocQ1tzc3ex09f1vjLABgStnFVOhZeEEZ7 zwOtDQ+f6iRPPIEJdO4bPAaedQ== X-Received: by 2002:a0c:bda0:: with SMTP id n32mr30978862qvg.164.1593694678083; Thu, 02 Jul 2020 05:57:58 -0700 (PDT) Received: from localhost ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id p7sm7930994qki.61.2020.07.02.05.57.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jul 2020 05:57:57 -0700 (PDT) Date: Thu, 2 Jul 2020 08:57:57 -0400 From: Joel Fernandes To: Tim Chen Cc: Vineeth Remanan Pillai , Peter Zijlstra , Nishanth Aravamudan , Julien Desfossez , tglx@linutronix.de, pjt@google.com, torvalds@linux-foundation.org, linux-kernel@vger.kernel.org, subhra.mazumdar@oracle.com, mingo@kernel.org, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Aaron Lu , Aubrey Li , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineethrp@gmail.com, Chen Yu , Christian Brauner , Aaron Lu , paulmck@kernel.org Subject: Re: [RFC PATCH 06/16] sched: Add core wide task selection and scheduling. Message-ID: <20200702125757.GB439212@google.com> References: <20200701232847.GA439212@google.com> <200c81ef-c961-dcd5-1221-84897c459b05@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200c81ef-c961-dcd5-1221-84897c459b05@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 01, 2020 at 05:54:11PM -0700, Tim Chen wrote: > > > On 7/1/20 4:28 PM, Joel Fernandes wrote: > > On Tue, Jun 30, 2020 at 09:32:27PM +0000, Vineeth Remanan Pillai wrote: > >> From: Peter Zijlstra > >> > >> Instead of only selecting a local task, select a task for all SMT > >> siblings for every reschedule on the core (irrespective which logical > >> CPU does the reschedule). > >> > >> There could be races in core scheduler where a CPU is trying to pick > >> a task for its sibling in core scheduler, when that CPU has just been > >> offlined. We should not schedule any tasks on the CPU in this case. > >> Return an idle task in pick_next_task for this situation. > >> > >> NOTE: there is still potential for siblings rivalry. > >> NOTE: this is far too complicated; but thus far I've failed to > >> simplify it further. > >> > >> Signed-off-by: Peter Zijlstra (Intel) > >> Signed-off-by: Julien Desfossez > >> Signed-off-by: Vineeth Remanan Pillai > >> Signed-off-by: Aaron Lu > >> Signed-off-by: Tim Chen > > > > Hi Peter, Tim, all, the below patch fixes the hotplug issue described in the > > below patch's Link tag. Patch description below describes the issues fixed > > and it applies on top of this patch. > > > > ------8<---------- > > > > From: "Joel Fernandes (Google)" > > Subject: [PATCH] sched: Fix CPU hotplug causing crashes in task selection logic > > > > The selection logic does not run correctly if the current CPU is not in the > > cpu_smt_mask (which it is not because the CPU is offlined when the stopper > > finishes running and needs to switch to idle). There are also other issues > > fixed by the patch I think such as: if some other sibling set core_pick to > > something, however the selection logic on current cpu resets it before > > selecting. In this case, we need to run the task selection logic again to > > make sure it picks something if there is something to run. It might end up > > picking the wrong task. Yet another issue was, if the stopper thread is an "It might end up picking the wrong task" needs to be: "We might end up picking a different task but that's Ok". > > unconstrained pick, then rq->core_pick is set. The next time task selection > > logic runs when stopper needs to switch to idle, the current CPU is not in > > the smt_mask. This causes the previous ->core_pick to be picked again which > > happens to be the unconstrained task! so the stopper keeps getting selected > > forever. > > > > That and there are a few more safe guards and checks around checking/setting > > rq->core_pick. To test it, I ran rcutorture and made it tag all torture > > threads. Then ran it in hotplug mode (hotplugging every 200ms) and it hit the > > issue. Now it runs for an hour or so without issue. (Torture testing debug > > changes: https://bit.ly/38htfqK ). > > > > Various fixes were tried causing varying degrees of crashes. Finally I found > > that it is easiest to just add current CPU to the smt_mask's copy always. > > This is so that task selection logic always runs on the current CPU which > > called schedule(). > > > It looks good to me. Thank you for your review! Could I add your Reviewed-by tag to the patch? - Joel > Thanks. > > Tim