Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp542418pxb; Thu, 5 Nov 2020 06:51:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJza2DBFd0Eqi1GgMlRv2sKoH9ICayfLq8TBw8+AThBz02EC1i/pB+cfgZvEI640Tv5EoVCp X-Received: by 2002:a50:d5dd:: with SMTP id g29mr3011879edj.379.1604587915467; Thu, 05 Nov 2020 06:51:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604587915; cv=none; d=google.com; s=arc-20160816; b=TpSOUd8f/FQcInj1SO90PGS6cW7ABTRguYIoevYlvcCvRTuWHkA7zROhI4EI6c3Rvq l06pbrt3OgujRVaHEeR9aarLegCJ6A+36n76z8B44TVRIqh1KkujxnhnauFkK/IijMm/ UFZzAz3A+0nCVoQnj4FW9alnJtkcta8MLeqzGAY6lqsXSc3JE6BZnRQVZ6v0LoeCeLXj iIiOA+97aOvY7M49nINvq+/EBPUT+ZYDMSESB9Ysm1D0XgLAJXpas92h6pRyHqHBtrUV TFz99uBKV49M8dGcvVDiZT/rJwKW5KZ5I3Fimk1+brzmvvwu2cvflpT6JMI269HbyAMr C8Gw== 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=mBwzMjDkfddA3GG6Qd4/im/kzhg/3gl/2vjmX28S6D0=; b=ZKwvadVb17GWwBArRymWpWwL/vSAbCkxjN5IrhY9fWZ+dY9mUYIxUi5eqY54O3SxzT Z41BRSvJZMd6vKjOxnkU75Zz5H2M0oVbk4LA7EL7XSZ0MXUVNZjv5Z+pScAt4lNDfWnG BwDxnD3nlYFKt/DjGqr97FMGzu6ZBhrxhoHQt8mWPFXUVPSY97GPs4MreG3gk22w60E4 QYCcmOY8awDPJhbK0hQXUgZze7NpnN7e3oWCsWBZXtQbJ5kqWS9wpOzGJDKDtn3VeCrj /XwZsUV9WUg1gFnv9vjOmhtSgksMXRMoPCd9FCAIRZ9gq0lJTd4GPv+Rt/PnUVteZZTu dfaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Rqgw01k0; 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 t1si1283644ejb.712.2020.11.05.06.51.32; Thu, 05 Nov 2020 06:51:55 -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=Rqgw01k0; 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 S1731171AbgKEOtW (ORCPT + 99 others); Thu, 5 Nov 2020 09:49:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730871AbgKEOtW (ORCPT ); Thu, 5 Nov 2020 09:49:22 -0500 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 24BDBC0613CF for ; Thu, 5 Nov 2020 06:49:21 -0800 (PST) Received: by mail-qk1-x744.google.com with SMTP id a65so1331844qkg.13 for ; Thu, 05 Nov 2020 06:49:21 -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=mBwzMjDkfddA3GG6Qd4/im/kzhg/3gl/2vjmX28S6D0=; b=Rqgw01k0N8Miti1WyIH/0v3+iJXf6kmv2E2nZMHr2U5Iz/AyW23fuPu+418AIuQycY TPINfyr4iEO5T0l5UTJmer/FiQeOmmOW5YIyDY9Wa0YCm0bdNRZ4kVD6fca57B3yqvJF 3t7QX/TLP5+ZAZYkLfpqyeEgkruP9PDipZe7c= 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=mBwzMjDkfddA3GG6Qd4/im/kzhg/3gl/2vjmX28S6D0=; b=tU+qEHZRlTlTNSNU1HyTmVwAb4biPIYeqFa8jKGc/BaSob2g5TVmzcOqEP8wAV1iwR 5sE+rgMYaUYJmdeULs7IrNRdYPR3YvvmdcM9ZXyONuE1KBAjsDqc8mfP3G35jazJWDqx 1lf46E2bnBZSvZ3px1BW4jC8aAzGgkQ9rkwl6ocv7VxkfKN2oH5SY46Op4aehHaH1sMI KU/kaVD9hmqPMW+bYvjgUljCTgvAvwWkJOJ36FOe+Crlog2if/aC7DLNAI/eW9KTay17 irFMcGsP3ZKa5hKWxkDFolsS9nhcc5/HXnNV0wV3g9PeDrgIN2amzfcZZgVtAh821KP5 8Cag== X-Gm-Message-State: AOAM5326bK1MD+XTiM/mkW8IzfpjrPPoP9yRFIORFym7Zm6Nu6M7Hdpr Jh5slGN8BsJEIytQLxxCtJPLEA== X-Received: by 2002:a05:620a:79a:: with SMTP id 26mr2296473qka.331.1604587760332; Thu, 05 Nov 2020 06:49:20 -0800 (PST) Received: from localhost ([2620:15c:6:411:cad3:ffff:feb3:bd59]) by smtp.gmail.com with ESMTPSA id s43sm1026874qte.52.2020.11.05.06.49.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Nov 2020 06:49:19 -0800 (PST) Date: Thu, 5 Nov 2020 09:49:19 -0500 From: Joel Fernandes To: chris hyser Cc: Nishanth Aravamudan , Julien Desfossez , Peter Zijlstra , 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, Aubrey Li , "Paul E. McKenney" , Tim Chen Subject: Re: [PATCH v8 -tip 17/26] sched: Split the cookie and setup per-task cookie on fork Message-ID: <20201105144919.GA2656962@google.com> References: <20201020014336.2076526-1-joel@joelfernandes.org> <20201020014336.2076526-18-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 Wed, Nov 04, 2020 at 05:30:24PM -0500, chris hyser wrote: [..] > + wr.cookies[0] = cookie; > > + } else > > + /* > > + * t1 joining t2 > > + * CASE 1: > > + * before 0 0 > > + * after new cookie new cookie > > + * > > + * CASE 2: > > + * before X (non-zero) 0 > > + * after 0 0 > > + * > > + * CASE 3: > > + * before 0 X (non-zero) > > + * after X X > > + * > > + * CASE 4: > > + * before Y (non-zero) X (non-zero) > > + * after X X > > + */ > > + if (!t1->core_task_cookie && !t2->core_task_cookie) { > > + /* CASE 1. */ > > + cookie = sched_core_alloc_task_cookie(); > > + if (!cookie) > > + goto out_unlock; > > + > > + /* Add another reference for the other task. */ > > + if (!sched_core_get_task_cookie(cookie)) { > > + return -EINVAL; > > should be: ret = -EINVAL; Fixed now, thanks. thanks, - Joel > > > + goto out_unlock; > > + } > > + > > + wr.tasks[0] = t1; > > + wr.tasks[1] = t2; > > + wr.cookies[0] = wr.cookies[1] = cookie; > > + > > + } else if (t1->core_task_cookie && !t2->core_task_cookie) { > > + /* CASE 2. */ > > + sched_core_put_task_cookie(t1->core_task_cookie); > > + sched_core_put_after_stopper = true; > > + > > + wr.tasks[0] = t1; /* Reset cookie for t1. */ > > + > > + } else if (!t1->core_task_cookie && t2->core_task_cookie) { > > + /* CASE 3. */ > > + if (!sched_core_get_task_cookie(t2->core_task_cookie)) { > > + ret = -EINVAL; > > + goto out_unlock; > > + } > > + > > + wr.tasks[0] = t1; > > + wr.cookies[0] = t2->core_task_cookie; > > + > > + } else { > > + /* CASE 4. */ > > + if (!sched_core_get_task_cookie(t2->core_task_cookie)) { > > + ret = -EINVAL; > > + goto out_unlock; > > + } > > + sched_core_put_task_cookie(t1->core_task_cookie); > > + sched_core_put_after_stopper = true; > > + > > + wr.tasks[0] = t1; > > + wr.cookies[0] = t2->core_task_cookie; > > + } > > + > > + stop_machine(sched_core_task_join_stopper, (void *)&wr, NULL); > > + > > + if (sched_core_put_after_stopper) > > + sched_core_put(); > > + > > + ret = 0; > > +out_unlock: > > + mutex_unlock(&sched_core_mutex); > > + return ret; > > +} > > + > > +/* CGroup interface */ > > static u64 cpu_core_tag_read_u64(struct cgroup_subsys_state *css, struct cftype *cft) > > { > > struct task_group *tg = css_tg(css); > > @@ -9207,18 +9435,9 @@ static int __sched_write_tag(void *data) > > * when we set cgroup tag to 0 when the loop is done below. > > */ > > while ((p = css_task_iter_next(&it))) { > > - p->core_cookie = !!val ? (unsigned long)tg : 0UL; > > - > > - if (sched_core_enqueued(p)) { > > - sched_core_dequeue(task_rq(p), p); > > - if (!p->core_cookie) > > - continue; > > - } > > - > > - if (sched_core_enabled(task_rq(p)) && > > - p->core_cookie && task_on_rq_queued(p)) > > - sched_core_enqueue(task_rq(p), p); > > + unsigned long cookie = !!val ? (unsigned long)tg : 0UL; > > + sched_core_tag_requeue(p, cookie, true /* group */); > > } > > css_task_iter_end(&it); > > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c > > index c8fee8d9dfd4..88bf45267672 100644 > > --- a/kernel/sched/debug.c > > +++ b/kernel/sched/debug.c > > @@ -1024,6 +1024,10 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, > > __PS("clock-delta", t1-t0); > > } > > +#ifdef CONFIG_SCHED_CORE > > + __PS("core_cookie", p->core_cookie); > > +#endif > > + > > sched_show_numa(p, m); > > } > > > > -chrish