Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp121719lqe; Fri, 5 Apr 2024 15:04:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXi04JK7ecnTn6qL0EdmQkb42NbzO2Wsx0bNO5GTaTpFF8A4+WWs3BF8s4j1ekUbf4WgkCQwTCMEf75qvnxfbPrizSFyvJCgcQQbf2WkQ== X-Google-Smtp-Source: AGHT+IGbcOmpV58UGqvIlmJNZwSzXYP6J+DUB1bFDCppsK1uuqcYkkMG4ku/+8+uix8ftpZLN4mV X-Received: by 2002:a05:6102:50ac:b0:476:e73b:4299 with SMTP id bl44-20020a05610250ac00b00476e73b4299mr2349241vsb.27.1712354677156; Fri, 05 Apr 2024 15:04:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712354677; cv=pass; d=google.com; s=arc-20160816; b=wn4vWJ86RMlQYLgTqyX8ZSS7T/9rve6EgORkt6bX46y37a20NT2K86TQrA4utAQ4ci +scqP/n0hw9pIr0xCB5zLeBajq8cNwpXwxeF0McFyJL3hK2OFKTI6P0rAeZFwkbo9OvM STGWsBXtjs452s77fyFOn6LiDb3wl2ReTPksKKZS78zYPCJ+uSUXTysI+IiEwFrFX+fs 3LaZ9GbYX7hORhdn7UhW4qfyT36HBgg1w7ivjpgxxe9/4sRpWJZX+HbkZs1rct0d95JV tCPr5urFJzs2vVDL1HipDJCv2CGzcbU2stnm0Tp7fyuaXYsrXAUb5eQ/8s1c0jhAR6Z7 YilQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=oYg/cohccThrETIY2rOcIdkjzZTkorKuffC7jTSrYuY=; fh=4z/8FkEeD3zPrHDEMrouThYbkxFWf1N/b/biZBN9Qtk=; b=o52499P/FhugH8rYumPL+YBNlz0yXhkQtEIx1E7A3ivicV2EN0vuKgafN8w53cYuKo L6wU1R3t209MGmfHwiYzhlg0c0l3KEL57qLj2gDDgFiBGFwFIO/5BptX1lUYkhFo7rRf utRTaU8MWAx/wVL9r+NPZCnmnyw5zZH2VifSV2N5kRUCZaxSTy23L/mXF94qm5uRxGkh us58i+1aJQd78XbAnWutetvuwYnUmeDtW1uFOw4Ze9VjZmg6m7ZAGuQ2DgyMiZehEZp8 7xLiEaG3H80YEE2zl+5KA2zJvszj+2vgEkMmPnoIlvdc1lUiwPzQVFsej85sSuuoCiMg 3QtQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AmIB9aOx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133662-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id u8-20020a056102374800b00479c3a4a545si498046vst.20.2024.04.05.15.04.36 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Apr 2024 15:04:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133662-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=AmIB9aOx; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-133662-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133662-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 50F091C216DC for ; Fri, 5 Apr 2024 22:04:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 07C3217555A; Fri, 5 Apr 2024 22:04:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="AmIB9aOx" Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) (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 5AAFB17554D for ; Fri, 5 Apr 2024 22:04:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712354666; cv=none; b=ZHgLN98GUUImB+xYBi7iDw2ggqOiplR3fqAw7v1LnuAleDrXnJU8RDkKcFpDf+jt2EZuHA34yjkf0oUPoqIFx+exPCo0H28YNN4p5YdRfdHCMiixaVY2yNsJed0KmnpMfKZegmqrqjHHc7rxD0J79OAoAi03fJsYHTBi6VahJ1g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712354666; c=relaxed/simple; bh=3ozwbhvvmQMH/HqtEAnVYhdm4dpfr4GO8gu60e+SKRA=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=u7msTZJDwdFUw4PauZTgLzKUT6MZujCy/W6Ocd6aWDoAC4tH3W2AJHBJWbP8G8sdl2CcFt02lbhKgBmjBDy3nExz1ytPMvmxoTzvtYSgTHpjmJFUAIWpj2fTzQN7lThtOuWI/xvZsScRDeLDKdw9WQ0hJUejofH5D3R5oiANV2M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=AmIB9aOx; arc=none smtp.client-ip=209.85.166.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-il1-f182.google.com with SMTP id e9e14a558f8ab-369de5d5833so13085ab.1 for ; Fri, 05 Apr 2024 15:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1712354663; x=1712959463; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oYg/cohccThrETIY2rOcIdkjzZTkorKuffC7jTSrYuY=; b=AmIB9aOxrEitVl4WXR9IL/GHt7ryrz/oLYNxKjUD4Tc+kwnW/Lgcfhyg/bXP82YtgC uYW8ATlg0vTmgJ4pfzwtM0+oc7Mg8XgRwQ1zQmJ1YLKOfxdnQg+XSLTJ5iIISShhNPBc CuSTwqYzRFPILE6iDvdFvijsUkU63OJoAz8AnGay8BXRydtHHDakzkrWE7CG4gA/K6J1 JORXacVUIsBh0BbxhWFBTRT/DZf3hZz8ruWicJA+haNOGxG15e0mV22Y81EqcoeNc/pe jHub87a/h3IS4MLb64KcRcEJ2NP8OgdPSBGP59vosXBGxf1JhfT8TX4RqsFTJ0E2eBgQ mwJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712354663; x=1712959463; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oYg/cohccThrETIY2rOcIdkjzZTkorKuffC7jTSrYuY=; b=MSn7Oc9lReN4Irr654szkvRV6DK6vDEa86ILFBcuS4mn8lsdqQUFJjb0XQkf8LlaJ6 ZGeg6KNZIch+qTvFApibkoY7txxsoVXGsmveTyF2NhVJy5fOvGopgWiVgoYqwAuinh3P yM35/96BqzRnO6un8RU94/lvP7LUVbGCZ5aCt8rDUIM/UbHRiPENcH9Ah5yCHkSm16Tj cxt862hcThjkCZiRBdzeWDNPBNu9h7DJJ3pvHwgiBzuCLCTT7eEMhcb9jM5zsAo5uW2X JsNWyu8xyL+gTYJkUDZTqOe6pFOJr0jMw1ApZFg8+uYdgE5PCdQwPLFokRuMcu1Xuf/V mm5Q== X-Forwarded-Encrypted: i=1; AJvYcCWooXn7ayW51kYAQAeM3O9d95E+EIGsDoCzN3JaPBUrGPwuJMEpAfGsPlCDgXQeugj/kbL/wG97+7MmpPFpx/h0PbHcQ5KFip07NydB X-Gm-Message-State: AOJu0YwLD/nzYNVQD2XnYMnWrKMUahLLVZqrr7y8Re5+knXUw7+Tm4Pd FQ5bpxkRI/j28IJV3KX4oCU92jcXBWy7VKgUr9XPmoqBFQE7YQHRIH5uJdKiXpDWS+G7y9vVSjb peoUg8YS7GG1me59ZCqU7NMD9Q/r25PPeF8oJ X-Received: by 2002:a05:6e02:1a45:b0:36a:1201:c733 with SMTP id u5-20020a056e021a4500b0036a1201c733mr36689ilv.11.1712354663283; Fri, 05 Apr 2024 15:04:23 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240325172707.73966-1-peternewman@google.com> <20240325172707.73966-2-peternewman@google.com> In-Reply-To: From: Peter Newman Date: Fri, 5 Apr 2024 15:04:11 -0700 Message-ID: Subject: Re: [PATCH v1 1/6] x86/resctrl: Move __resctrl_sched_in() out-of-line To: Reinette Chatre Cc: Fenghua Yu , James Morse , Stephane Eranian , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , Uros Bizjak , Mike Rapoport , "Kirill A. Shutemov" , Rick Edgecombe , Xin Li , Babu Moger , Shaopeng Tan , Maciej Wieczor-Retman , Jens Axboe , Christian Brauner , Oleg Nesterov , Andrew Morton , Tycho Andersen , Nicholas Piggin , Beau Belgrave , "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Reinette, On Thu, Apr 4, 2024 at 4:09=E2=80=AFPM Reinette Chatre wrote: > > Hi Peter, > > On 3/25/2024 10:27 AM, Peter Newman wrote: > > __resctrl_sched_in() is unable to dereference a struct rdtgroup pointer > > when defined inline because rdtgroup is a private structure defined in > > internal.h. > > Being inline has nothing to do with whether it can reference a struct rdt= group > pointer, no? No, but it has a lot to do with whether it can de-reference a struct rdtgroup pointer in order to obtain a CLOSID or RMID, as doing so would pull the definitions for struct rdtgroup and struct mongroup into an external header. Before doing so, I would want to make sure implementing __resctrl_sched_in() inline is actually adding value. > > > > > This function is defined inline to avoid impacting context switch > > performance for the majority of users who aren't using resctrl at all. > > These benefits can already be realized without access to internal > > resctrl data structures. > > > > The logic of performing an out-of-line call to __resctrl_sched_in() onl= y > > when resctrl is mounted is architecture-independent, so the inline > > definition of resctrl_sched_in() can be moved into linux/resctrl.h. > > > > Signed-off-by: Peter Newman > > ... > > > diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.= c > > index 0917c7f25720..8f92a87d381d 100644 > > --- a/arch/x86/kernel/process_32.c > > +++ b/arch/x86/kernel/process_32.c > > @@ -38,6 +38,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > @@ -51,7 +52,6 @@ > > #include > > #include > > #include > > -#include > > #include > > > > #include "process.h" > > diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.= c > > index 7062b84dd467..d442269bb25b 100644 > > --- a/arch/x86/kernel/process_64.c > > +++ b/arch/x86/kernel/process_64.c > > @@ -40,6 +40,7 @@ > > #include > > #include > > #include > > +#include > > > > #include > > #include > > With a change like this we should be very careful about what is included = when > the kernel is not built with resctrl and in its current form linux/resctr= l.h is > not ready for this. > > If CONFIG_X86_CPU_RESCTRL is not set linux/resctrl.h should have the bare= minimum, > just like asm/resctrl.h has. > > > @@ -53,7 +54,6 @@ > > #include > > #include > > #include > > -#include > > #include > > #include > > #include > > diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h > > index a365f67131ec..62d607939a73 100644 > > --- a/include/linux/resctrl.h > > +++ b/include/linux/resctrl.h > > @@ -304,4 +304,25 @@ void resctrl_arch_reset_rmid_all(struct rdt_resour= ce *r, struct rdt_domain *d); > > extern unsigned int resctrl_rmid_realloc_threshold; > > extern unsigned int resctrl_rmid_realloc_limit; > > > > +DECLARE_STATIC_KEY_FALSE(rdt_enable_key); > > + > > +void __resctrl_sched_in(struct task_struct *tsk); > > + > > +/* > > + * resctrl_sched_in() - Assigns the incoming task's control/monitor ID= s to the > > + * current CPU > > + * > > + * To minimize impact to the scheduler hot path, this will stay as no-= op unless > > + * running on a system supporting resctrl and the filesystem is mounte= d. > > + * > > + * Must be called with preemption disabled. > > + */ > > +static inline void resctrl_sched_in(struct task_struct *tsk) > > +{ > > +#ifdef CONFIG_X86_CPU_RESCTRL > > + if (static_branch_likely(&rdt_enable_key)) > > + __resctrl_sched_in(tsk); > > +#endif > > +} > > + > > include/linux/resctrl.h should rather be divided to accommodate code > as below: > > #ifdef CONFIG_X86_CPU_RESCTRL > > static inline void resctrl_sched_in(struct task_struct *tsk) > { > if (static_branch_likely(&rdt_enable_key)) > __resctrl_sched_in(tsk); > } > > #else > > static inline void resctrl_sched_in(struct task_struct *tsk) {} > > #endif > > so that core code does not get anything unnecessary when CONFIG_X86_CPU_R= ESCTRL > is not set. Will do. Thanks! -Peter