Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1299331pxa; Sat, 15 Aug 2020 14:57:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFB96of3Gn1atoeCHQ0B4Ti0ljH1PhdwE6R0rI837Ci1OtaEjkuBT2qmUDo8dXm7n9MGtF X-Received: by 2002:aa7:d688:: with SMTP id d8mr8598763edr.168.1597528674616; Sat, 15 Aug 2020 14:57:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597528674; cv=none; d=google.com; s=arc-20160816; b=ouA5Rfd+8ZwIYDZFyBfiSYIx48RWArsJRIX4kWQVfJAhUcSFsMe99nT1I6Z2X8IA6w Wj8okLuEMnduCXbiJDtcSzChllfw9TrENtNdfkT1m+z3vwat8sy0lmlfyOPOR0zf0Qum 4+3kzY+zPDFwZwjExdjSMHEBwirc9S4xXpzqfXoBvQWKbD0ujih6Q3j8tvKDzphbyc6w L/F6fDInSIUX8+SICXXqZY3m+vKK/PyUlJCXKvalsEllgEEmWJn2rzvfkxC1epAR6Gjs oslPEvVfl5LxAKajxQ22HRNq/dqYIn1dqxWBHJ1EWd0UZgY/rjZ8NczPlogBIdvPHrbe HWlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vbniwNR3aKZ0L4CoWzsSoDjZIVxcefGHSxeEpUJZ0hc=; b=uDK2dnJ85SP8Z3SKjFJkCzj5/YNaeg3ddB73ZnIrqQsfWeAB/JdVdQfY39NZTYP2Z+ 4BsfLRCpi3+8X/2Ksvt2gP8V8wmquEJtxYuudr0dduO9EkTETbPwJst5Xuh9iTa2v05j Qhq0LcdBSO/1T9LefRDHGqFGKv1JzdUGcwk9Ld6gwdqVqduISJ2BHAjnMqH5BefGx/u7 RGJG8l7852Jcw/lOkOv2kD/cqaQGqliNRTjvt//kv2ao+RzmQT1X5Oja2cjSc8DOcOUe 4A1u+XpmfgX5SnrVM7k9f6O7N5OEDHlDeKjMqXSJfBWjbQn4fmwJvRvE+vKd4U7oLXqr ynZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=CLaLDaVS; 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 n6si6619345ejg.175.2020.08.15.14.57.31; Sat, 15 Aug 2020 14:57:54 -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=CLaLDaVS; 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 S1729382AbgHOV4G (ORCPT + 99 others); Sat, 15 Aug 2020 17:56:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729039AbgHOVwO (ORCPT ); Sat, 15 Aug 2020 17:52:14 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8819C06137A for ; Fri, 14 Aug 2020 20:19:33 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id 2so10162586qkf.10 for ; Fri, 14 Aug 2020 20:19:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vbniwNR3aKZ0L4CoWzsSoDjZIVxcefGHSxeEpUJZ0hc=; b=CLaLDaVSSaOthzY7gj1/EAO/pRnF2RWI6hfa4ynUe7KqmWc+DGlX2ACZOU1gh16HxH aodTD9ByW0xt4FgXGtwGU/SD7Kn16uBl6/ThKLo2j/c6IDaMkhBwWj7k6ckY62nKCIbL KRdpyOXY4T3U2n9LwDx7jNU0zXN1Zn0yFS5oc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vbniwNR3aKZ0L4CoWzsSoDjZIVxcefGHSxeEpUJZ0hc=; b=eatPwjN8X6lfIDZr9f9SqPQ377W6cyTUhLEpwjh++UuchvI9+nT0O725IYNaIXzrV/ vVCnfOZpMfZX9DB/f3yLnpMe1kY8bkwzvDQNp51d8RvTbmi1UENefIULDYbfb4isFWro yPwM1CDhgj77Ckvrjv5SDhZ+1mywh8CG+uAaeC9Xj5ey6MLN2Nn929jv1LqJmgQrtQcL srzBypTSu7lDF5ndaLpVzlTvAC3VmdrUlw8NWQvTa8oNuVlkdJJTMG4uyPK63bHnkJPX HeenCisWIu0Chzx2yXJY0qVFztWhK40OYeYgnz4dSDH0SbM9kCAG0BdGTLxYnIiYngOI LN3g== X-Gm-Message-State: AOAM532XKhFQ2ORbjmeSBxvVGMrNbRJ8fyM3fDFv1z1FJclVMV5i094d JhByhSpFcaej1J40XPWGK7ymmdxPRu6kjw== X-Received: by 2002:a37:9c7:: with SMTP id 190mr4379796qkj.303.1597461572672; Fri, 14 Aug 2020 20:19:32 -0700 (PDT) Received: from joelaf.cam.corp.google.com ([2620:15c:6:12:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id p12sm10055199qkk.118.2020.08.14.20.19.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Aug 2020 20:19:32 -0700 (PDT) From: "Joel Fernandes (Google)" To: linux-kernel@vger.kernel.org Cc: Vineeth Pillai , Joel Fernandes , Aaron Lu , Aubrey Li , Julien Desfossez , Kees Cook , "Paul E. McKenney" , Paul Turner , Peter Zijlstra , Steven Rostedt , Thomas Gleixner , Tim Chen , Tim Chen , Vincent Guittot , x86@kernel.org (maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)), fweisbec@gmail.com, kerrnel@google.com, Phil Auld , Valentin Schneider , Paolo Bonzini , Chen Yu , Christian Brauner Subject: [PATCH RFC 09/12] sched/coresched: Use for_each_cpu(_wrap)_or for pick_next_task Date: Fri, 14 Aug 2020 23:19:05 -0400 Message-Id: <20200815031908.1015049-10-joel@joelfernandes.org> X-Mailer: git-send-email 2.28.0.220.ged08abb693-goog In-Reply-To: <20200815031908.1015049-1-joel@joelfernandes.org> References: <20200815031908.1015049-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vineeth Pillai During a CPU hotplug event, schedule would be called with the hotplugged CPU not in the cpumask. So use for_each_cpu(_wrap)_or to include the current cpu in the task pick loop. Signed-off-by: Vineeth Pillai Co-developed-by: Joel Fernandes (Google) Signed-off-by: Joel Fernandes (Google) --- kernel/sched/core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel/sched/core.c b/kernel/sched/core.c index ff13254ed317..3e9df8221c62 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -4663,7 +4663,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) /* reset state */ rq->core->core_cookie = 0UL; - for_each_cpu(i, smt_mask) { + for_each_cpu_or(i, smt_mask, cpumask_of(cpu)) { struct rq *rq_i = cpu_rq(i); trace_printk("CPU %d is in smt_mask, resetting\n", i); @@ -4685,7 +4685,7 @@ pick_next_task(struct rq *rq, struct task_struct *prev, struct rq_flags *rf) */ for_each_class(class) { again: - for_each_cpu_wrap(i, smt_mask, cpu) { + for_each_cpu_wrap_or(i, smt_mask, cpumask_of(cpu), cpu) { struct rq *rq_i = cpu_rq(i); struct task_struct *p; @@ -4774,6 +4774,9 @@ next_class:; rq->core->core_pick_seq = rq->core->core_task_seq; next = rq->core_pick; rq->core_sched_seq = rq->core->core_pick_seq; + + /* Something should have been selected for current CPU */ + WARN_ON_ONCE(!next); trace_printk("picked: %s/%d %lx\n", next->comm, next->pid, next->core_cookie); /* @@ -4784,7 +4787,7 @@ next_class:; * their task. This ensures there is no inter-sibling overlap between * non-matching user state. */ - for_each_cpu(i, smt_mask) { + for_each_cpu_or(i, smt_mask, cpumask_of(cpu)) { struct rq *rq_i = cpu_rq(i); WARN_ON_ONCE(!rq_i->core_pick); -- 2.28.0.220.ged08abb693-goog