Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2283313pxb; Fri, 5 Feb 2021 13:47:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxbbbT0QDXL4XUk3KwlnuP/4lcyBGxFtXFM9/Srk7pjJeb7p4kI174EK3CNKeoHeZhGj/DV X-Received: by 2002:a17:906:fcb5:: with SMTP id qw21mr5893710ejb.391.1612561650675; Fri, 05 Feb 2021 13:47:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612561650; cv=none; d=google.com; s=arc-20160816; b=xjDnKMyLenZlJxDd2hPy2isCKqOAATtlYJz9YnnC3vmOzClljyFHQU7To5abhqEmOh DLwLeC4ukGaK/gv7VXlOYiOAtNYDYXFxq1G6ync6ZpkqNPyvBXdTS5Rfb5cw1xSbBeti ZSAWzrsKUr0FszFOBj+u1+9/7sW62XJ3F2h9fHzkvrzPa3u4ru/4K7WLVK2t9Z4rQqf1 yhfGvuC5UR9jN8rYBEsMbIESx6HC7duWyw1ffHB4RY8ZtEE0QhRVu107MqFz6POAx+Hz bsSbH9IfLEmcXqg5YbMlrpQT1vyXNkHetteAwqQzvOU14wrFqESjBNXiMhIl9sfaP5tn oqUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=RZ4pHLDiApBJAX4+SZTYvtkIoH8eBLs6rM4tc6HHOb4=; b=ZkYBHIw/qL06RJcvmCE6IGaxX/ZPF8r/MDXPKrgYEHt+HfwJnRmCAhtj8FKFTaPWw8 7NTq/NMoyusRJgI0BGGtAIt0a240rHmHxF16XdfCkHXFXW9rS2HpNLYallP0IsdDTm+V 5tPIR3ewy3zlxna2WAvqy+tDwu9Q3ZKyecPobQpHiqNMLnJafN1Qih0rTHQG1Z/pyw7i uf5NCQKlNjpNIMhIlUZc2R7gAg82FbQuIEeN4zLB+Ylj62duZzfYcmCBDrFyfkSMzH/h 9zdOTcc9U59NPY3IFP79X3ddUvDuLiRE4DLcrXzHQV7m5yfSYBIzjIX1rDCv685x6Ckj xUOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=hYsydKUN; 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 qc23si5975373ejb.467.2021.02.05.13.47.05; Fri, 05 Feb 2021 13:47:30 -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=@joelfernandes.org header.s=google header.b=hYsydKUN; 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 S230262AbhBEVnT (ORCPT + 99 others); Fri, 5 Feb 2021 16:43:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233016AbhBEO76 (ORCPT ); Fri, 5 Feb 2021 09:59:58 -0500 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16457C06174A for ; Fri, 5 Feb 2021 08:37:34 -0800 (PST) Received: by mail-qv1-xf2f.google.com with SMTP id u20so3714322qvx.7 for ; Fri, 05 Feb 2021 08:37:34 -0800 (PST) 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=RZ4pHLDiApBJAX4+SZTYvtkIoH8eBLs6rM4tc6HHOb4=; b=hYsydKUNEHn0p2d/mYnQEoYLwRRaK0kyows4etlt0PYfXW7AY21IngjDvFFC8KFn0J BfT4imr2GMmTV9TahiRR+3D8/Q2SQFOUoN8n/0yC2+LxO/IeNymqe2EjtuEi70SGdyZu lLVVaL3VWAV5eNL3CQMZlZnprr9GKYKQNvNwQ= 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=RZ4pHLDiApBJAX4+SZTYvtkIoH8eBLs6rM4tc6HHOb4=; b=L784swYvHHPeEFvaxOzlfqoco6GEMN10DVpGHL7BEdwSYyutqUOBO53d0Dpkn1cjbm i5mAO8zpOggNjtmQDBEgsiCL84DdHePgcuhqX9ynvWhvD2UOw67uV3RJkefkWE/Ucr81 vKfj/CKFmGNOQkCAjXnk7zaD6vhVOxE3/dXzNVovNG9UvRiwlPKnyb64H7FB1Z3HTm8+ usrsdVWDXI4MiOoXudiRzdRl23KybFllMsv2ngdvMYkSXH7wqISXhp+GKJOgXpLnGUzU mYeMG0V2l9RHif0qcT97dtIqNhykjub1q3NUI2JIVyYtLJmFXCKeiJPjxI5+r60Y1HMi pzCA== X-Gm-Message-State: AOAM533BHyaDkX4jPrCwlpU2yaS61Ovlr6HbkPbJAhp4ApA23DQEoDbf oBYTh3f3jS2jyUCUkLIZ+lfKNg== X-Received: by 2002:a0c:b59f:: with SMTP id g31mr5057374qve.28.1612543053209; Fri, 05 Feb 2021 08:37:33 -0800 (PST) Received: from localhost ([2620:15c:6:411:7d0b:8b50:779:2056]) by smtp.gmail.com with ESMTPSA id k14sm8220219qtj.40.2021.02.05.08.37.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 08:37:31 -0800 (PST) Date: Fri, 5 Feb 2021 11:37:31 -0500 From: Joel Fernandes To: Peter Zijlstra Cc: Nishanth Aravamudan , Julien Desfossez , Tim Chen , Vineeth Pillai , Aaron Lu , Aubrey Li , tglx@linutronix.de, linux-kernel@vger.kernel.org, mingo@kernel.org, torvalds@linux-foundation.org, fweisbec@gmail.com, keescook@chromium.org, kerrnel@google.com, Phil Auld , Valentin Schneider , Mel Gorman , Pawan Gupta , Paolo Bonzini , vineeth@bitbyteword.org, Chen Yu , Christian Brauner , Agata Gruza , Antonio Gomez Iglesias , graf@amazon.com, konrad.wilk@oracle.com, dfaggioli@suse.com, pjt@google.com, rostedt@goodmis.org, derkling@google.com, benbjiang@tencent.com, Alexandre Chartre , James.Bottomley@hansenpartnership.com, OWeisse@umich.edu, Dhaval Giani , Junaid Shahid , jsbarnes@google.com, chris.hyser@oracle.com, Ben Segall , Josh Don , Hao Luo , Tom Lendacky Subject: Re: [PATCH v10 2/5] sched: CGroup tagging interface for core scheduling Message-ID: References: <20210123011704.1901835-1-joel@joelfernandes.org> <20210123011704.1901835-3-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 04, 2021 at 03:52:53PM +0100, Peter Zijlstra wrote: > On Fri, Jan 22, 2021 at 08:17:01PM -0500, Joel Fernandes (Google) wrote: > > +static void sched_core_update_cookie(struct task_struct *p, unsigned long cookie, > > + enum sched_core_cookie_type cookie_type) > > +{ > > + struct rq_flags rf; > > + struct rq *rq; > > + > > + if (!p) > > + return; > > + > > + rq = task_rq_lock(p, &rf); > > + > > + switch (cookie_type) { > > + case sched_core_task_cookie_type: > > + p->core_task_cookie = cookie; > > + break; > > + case sched_core_group_cookie_type: > > + p->core_group_cookie = cookie; > > + break; > > + default: > > + WARN_ON_ONCE(1); > > + } > > + > > + /* Set p->core_cookie, which is the overall cookie */ > > + __sched_core_update_cookie(p); > > + > > + if (sched_core_enqueued(p)) { > > + sched_core_dequeue(rq, p); > > + if (!p->core_cookie) { > > + task_rq_unlock(rq, p, &rf); > > + return; > > + } > > + } > > + > > + if (sched_core_enabled(rq) && > > + p->core_cookie && task_on_rq_queued(p)) > > + sched_core_enqueue(task_rq(p), p); > > + > > + /* > > + * If task is currently running or waking, it may not be compatible > > + * anymore after the cookie change, so enter the scheduler on its CPU > > + * to schedule it away. > > + */ > > + if (task_running(rq, p) || p->state == TASK_WAKING) > > + resched_curr(rq); > > I'm not immediately seeing the need for that WAKING test. Since we're > holding it's rq->lock, the only place that task can be WAKING is on the > wake_list. And if it's there, it needs to acquire rq->lock to get > enqueued, and rq->lock again to get scheduled. > > What am I missing? Hi Peter, I did this way following a similar pattern in affine_move_task(). However, I think you are right. Unlike in the case affine_move_task(), we have schedule() to do the right thing for us in case of any races with wakeup. So the TASK_WAKING test is indeed not needed and we can drop tha test. Apologies for adding the extra test out of paranoia. thanks, - Joel