Received: by 2002:a05:6500:1b41:b0:1fb:d597:ff75 with SMTP id cz1csp132540lqb; Tue, 4 Jun 2024 07:11:26 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+PetteohKp4dcdagXcxDXqgeKTtK/7gCe6L3OEH3TUW1Sx+yUJbS+/RtCVM9ZY0TbpmafttHa20QgYKlzQpJseg0Lt5TBTUITVnmPBA== X-Google-Smtp-Source: AGHT+IEtmXYP3WBZWR7FgH/y+rlT6zE2SaFynVLQnmIiGiM/yWxacFyc+on3mSQ2LE0IqUqsZIui X-Received: by 2002:a17:902:eb8c:b0:1f4:5c6e:3a9b with SMTP id d9443c01a7336-1f63707e819mr144959335ad.44.1717510283296; Tue, 04 Jun 2024 07:11:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717510283; cv=pass; d=google.com; s=arc-20160816; b=f6i+oRYp13nB0CIV2d1Kiuhiaufj2xXsKs/umob86DP7ZmRUkUURHX5FDaUlPv1RA5 0UsRhA8CY1vEz3GtUyoHroqbWFPOKU2Ma8PZ83oCZ5Hg6M0/ioAmzb1+P92I0nCj3Jjh JkmX0TvWt/T9MrW64m8/Z9SLY4O/1XoNVWucACMfPn90qwuzuQO5QjCr5QYjxAgabYBo VwG5XDS9b/MRB2eGI4zaftfKfT3pUiLE1NX+asR/RsOiTZOOas7aG0baqjF0ml+VY7TT WWtx/Jvto8VQYB6P34Nc5K+/g0Oz0mb6RBv6LGX3kre/Wlqr8s3UCeC89dzPVAtwU8fY i0yQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WHLll6BTIMUHEHBTeAtYvtf1ag837ymjZhmcP8Q3NO8=; fh=fRrmcslpWdV0rUAyCipKAnpi7UfvsFnRCn66NfB66V4=; b=0JtwpA0SKJk89rMdo8FRjwlim/X+EHOjHe+ctCaTyx+bLxzQts5vNUIlnz2yof8edE ElPaP0MoskL0vtlqtp45jOp1EckRWFNxlb7HKnJ2ihv3rLFjGO77a8fimtYBJ5aTdizh ifQUo8sX0skwR/+fG1eCGoqt6GIUtf1O93JD1VZdL/FqH8hwox66zY+NvlvDNn+S+Zne 1/WlWTkJE8ENNYr+FZRemyjhWuT+f44Rnf2VpBbVN5xdiV2HBFFdwuqDhA6V3kocLu/I pOcz+IjLapnX23Fgzquq5SF2SIrbvAMQfP407rIOn6laM0hWYqDaoZyzpmiO9kPakQqt tvQQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=AbTa8NuS; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-200780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200780-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d9443c01a7336-1f632426eabsi15928535ad.647.2024.06.04.07.11.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:11:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@layalina-io.20230601.gappssmtp.com header.s=20230601 header.b=AbTa8NuS; arc=pass (i=1 spf=pass spfdomain=layalina.io dkim=pass dkdomain=layalina-io.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-200780-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200780-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 00D6A281484 for ; Tue, 4 Jun 2024 14:11:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D94D6383AC; Tue, 4 Jun 2024 14:11:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b="AbTa8NuS" Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EFAD7179AF for ; Tue, 4 Jun 2024 14:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717510269; cv=none; b=Q8UjnY4iDLJd783NCweFty/c6As8GensA4wqWJmgpJc9S++hWfkuBHYpDLH6GxV/XEn6spRAarn6zy6aAzQZN5TJqxfSProQyc24hgcKVl1puqmIdcw4T9wo5yLDLTtH3Ny2lyrSHDis3xLJkkoVe5/OZVokHMZ6x6SdMP7TiwU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717510269; c=relaxed/simple; bh=3J224HS/i/m5wpovzB18NFbdiZs3oTx/Dp+0hVsFnGw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=P7wcfQIf47eLTOjm5YRaTWQIKgeJkBf6iST6o4XBLqiTf4kIVCTMYHmZQSQIXSZ/QJIvD/IR5iVnB6hcWYGos9YYnOGLsbAbprvMX2TFpgQUnWQkCjMkBzo3OKim27p47NEqmKFQ2OMKVHQUC16zbYFCumZ3y1tZrrEvOLQ8anM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io; spf=pass smtp.mailfrom=layalina.io; dkim=pass (2048-bit key) header.d=layalina-io.20230601.gappssmtp.com header.i=@layalina-io.20230601.gappssmtp.com header.b=AbTa8NuS; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=layalina.io Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=layalina.io Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-42135a45e2aso26976975e9.3 for ; Tue, 04 Jun 2024 07:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1717510265; x=1718115065; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=WHLll6BTIMUHEHBTeAtYvtf1ag837ymjZhmcP8Q3NO8=; b=AbTa8NuSSkbpuFgMUVm4u4pWCeonA/cQ8UqqBWmPObOb36QVXihtpwhO0lZ62DZJNF J723VdsqX/De2da+jMN1XbSIlRpXaIrc8h1vNCZvM0QgXIiCg0ShlrcpDn/+EjDv46rn MRhmKkQvFDTeqvXY72VV/iqBlg4PzgI9q8hdDWYm8lMrFY3fiUgAoAPe3mgUaWtr/5Mk OxoCZp1vG7qcpViTtVuZkytgcqXtwqyIfSKOjNuB3BV81aCma5SqlxhY8qdljtFKzx9U AoUsl3xxhSY416wfVSFZdUBtJyAPRSXIaGenKmLdSqvgR8rM6EdDD0u81f//W+Bi2FXC zEqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717510265; x=1718115065; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=WHLll6BTIMUHEHBTeAtYvtf1ag837ymjZhmcP8Q3NO8=; b=IOM6mIuLqbEJPacQyWzpZaFxMUynSVs7O/TldiPXrObTpzb9cPHbLO7B0Bqv1RDh4s fU2nnVwHBgCqLyk5NoBB4KbAMLGdFvWqNbEE3vdD8/6kVKamVygaPYiE6Jrz5OV+1WnD EHB0Vf4Vdrta3qzq/dxCDLbPhUIN1J2vOi5vWPaMlO31sh69onqCMDtVT8Fq0uZZeTU6 sIQUFkU/CtxSYrlsqmecgOmv5hiCgZErwPfQThWfF9ez9vizBzKou+3os8FXaPeMDM6o qepu00Txa+JTFk1FP3DzcrIM6re7r1AqgMhV05Zcu/xT9elssCu+ZBEC4yVzJGiaxCIy rLBg== X-Gm-Message-State: AOJu0YxKPl/tXW9DHov5MS5aq7WertyE1bjFcGimcSa047nMLFGgYdmA D4aMAC0uQVtE9md5VAuuzXdguYT9wS3qOOrrzpl/9TR+xt/7NgH5wGdXSIam1t4= X-Received: by 2002:a05:600c:1ca6:b0:41c:7bd:5a84 with SMTP id 5b1f17b1804b1-4212e07548amr115529045e9.17.1717510265372; Tue, 04 Jun 2024 07:11:05 -0700 (PDT) Received: from airbuntu ([87.127.96.170]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35e4f0fd15esm9168827f8f.68.2024.06.04.07.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 07:11:05 -0700 (PDT) Date: Tue, 4 Jun 2024 15:11:03 +0100 From: Qais Yousef To: John Stultz Cc: LKML , Peter Zijlstra , Joel Fernandes , Ingo Molnar , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Valentin Schneider , Steven Rostedt , Ben Segall , Zimuzo Ezeozue , Youssef Esmat , Mel Gorman , Daniel Bristot de Oliveira , Will Deacon , Waiman Long , Boqun Feng , "Paul E. McKenney" , Xuewen Yan , K Prateek Nayak , Metin Kaya , Thomas Gleixner , kernel-team@android.com, Connor O'Brien Subject: Re: [PATCH v10 7/7] sched: Split scheduler and execution contexts Message-ID: <20240604141103.idwodwyeecml4keh@airbuntu> References: <20240507045450.895430-1-jstultz@google.com> <20240507045450.895430-8-jstultz@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240507045450.895430-8-jstultz@google.com> On 05/06/24 21:54, John Stultz wrote: > From: Peter Zijlstra > > Let's define the scheduling context as all the scheduler state > in task_struct for the task selected to run, and the execution > context as all state required to actually run the task. > > Currently both are intertwined in task_struct. We want to > logically split these such that we can use the scheduling > context of the task selected to be scheduled, but use the > execution context of a different task to actually be run. > > To this purpose, introduce rq_selected() macro to point to the > task_struct selected from the runqueue by the scheduler, and > will be used for scheduler state, and preserve rq->curr to > indicate the execution context of the task that will actually be > run. This is subjective opinion of course. But I am not a fan of rq_selected(). I think we are better with more explicit rq->currs /* current sched context */ rq->currx /* current execution context */ and the helpers task_curr_sctx() task_curr_xctx() This will ensure all current users of rq->curr will generate a build error and be better audited what they are supposed to be. And I think the code is more readable this way. Another way to do it is to split task_struct to sched and exec context (rather than control the reference to curr as done here). Then curr would be always the same, but reference to its sched context would change with inheritance. ie: struct task_sctx { ... }; struct task_struct { struct task_sctx *sctx; /* exec context is embedded as-is */ ... }; Which means would just have to update all accessors to sched context to do extra dereference. Which I am not sure if a problematic extra level of indirection. I see the latter approach more intuitive and explicit about what is a sched context that is supposed to be inherited and what is not. I generally think breaking down task structure would be good. Hopefully the new data perf can help us make better decision on what attributes to group together. And generally this might be a good exercise to rethink its content which grown organicaly over the year. Maybe we want to create similar such smaller wrapper structs for other fields too. I **think** with this approach we would just need go fix compilation errors to do p->sctx->{attribute}. Proxy exec later would only update the reference to this struct to enforce inheritance for rq->curr->sctx to point to the donor's context.