From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f175.google.com (mail-pf1-f175.google.com [209.85.210.175]) (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 F31B6283FF0 for ; Sat, 15 Nov 2025 15:09:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763219400; cv=none; b=bj40ultWsUUNoZUjHcBBjxydNb434oQ+H5DgWiby63rkPPrK7ehMFy1RRLU7TsfzSpqfOfV8hSfW85fXHHHNIDSxjkjGYip9NEzdWhZFHlwsvNzgJhMDi5YMZ6RgfW0gs1MijWKizXrZgvkeUwQREcx4a1T0zszr5zbzN6Uk8dY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763219400; c=relaxed/simple; bh=9SA9SEdpJyHPt8tsp4kccmbvrFG5gu2WIbEuJq7mvJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SegHE2ha/+8X+YlgJ0qX9xnXM0d0/Y6ACqm3x2dQrChuYY+V315ebd0einPOSDD7InaNDPTlhADC75Bvp+Yk0HCPjoY7S7UV4kFeXi1UHF8DSSXDfdZXH4Zu/aSkG8pf3N0fwDpp3Flmt6rN6FWSOacPGUGhlS3n0PfgSR6kv7Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FJbErLXt; arc=none smtp.client-ip=209.85.210.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FJbErLXt" Received: by mail-pf1-f175.google.com with SMTP id d2e1a72fcca58-7ba92341f83so2300164b3a.0 for ; Sat, 15 Nov 2025 07:09:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1763219398; x=1763824198; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9SA9SEdpJyHPt8tsp4kccmbvrFG5gu2WIbEuJq7mvJw=; b=FJbErLXtU8bgqxHLdctt8zbwJon845Uu5fz6ysLb2rJa5T7Ab5Vo8beiZkbvJHFqA7 zpFdgwr82ImS0hvpgydizMysAfTNyP3fFskBZ/qj1o07UwM4TwkqAtI9+bEb69LNM+Rx BwPVySwULjjg7bfakaWVU2koQIa4gF4L7AvxAetvPCJKBIvEvyiXRw2ZY+85JU+tBxOc G+NwvS293UzoTEUFt8OD1oEjxJ+yqc2PALzTghq/gNUT/Rq+koMEhfo/1rrM5/adsOcF LO+zdTe4in6D/AdRRnqCNP4CWk6x/zFjAutbnv/RJqrP8lFmJMoGd0OvrHw/izY27Vm5 PwCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763219398; x=1763824198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=9SA9SEdpJyHPt8tsp4kccmbvrFG5gu2WIbEuJq7mvJw=; b=Kqn6e0f3qvn05cbV+GoGFwNbM3fIEit9uLuwuL67oi1t8IzNICIEU9p9c83ENYA//5 YT9X6l3FuJKitHKs1a9RcL/L1A+Vcb7WqVswvy2cNp4w7lJj7N6zbtkTRNgS0z1mELxm 4CBcFZVBLjZ+PAztAFE0j6rTGrCawOS1Sb0NrhZOabBvvCDGivIhkVwVBt0BTXPIJKsM xYkY1c3FkjAF8FLRf/mrurdoxiREVRk5uLpEhYbTwJw6Esjle151/Nbqw1Si8USYK7ta HMa8pDXLwgNqJ9lSkej51hNAzMX7wzfc1i383BE1MwU6GgX1viRx3QkMq8VcbOFJ0eDO 58nQ== X-Forwarded-Encrypted: i=1; AJvYcCUzLlJqm3FQ4cke6xHKnsB1KPzDY+QxsJp6tfkS5YH3W8t/JzXuq+3DGuhcxD8+xD/nnUhUxDfdLEzcFUM=@vger.kernel.org X-Gm-Message-State: AOJu0YxVhpVCLukgnLdOjvBDNhudULEJ9VyzWn5uLsPxTCoBJ1njqhiO 8wfWJXRYDP0hMjEYiKUzesPcyDBoi54Yaxk/He+UBl+94Jy49Ay7NPCr X-Gm-Gg: ASbGnctowADNl37f18rWrtENqANYVqLstCPyTb3pTJlEuiMMFY2ubjT00b0hmiw56cl nf88pp+opWf1Yya/q8vpIOwkQfSNDjuYhX18MjnMO5Qmm66ECI95edbRIxzTRcILiz1+fKTLfsw XIGAJPcUigaeGxOeDbu3y6edwJMvT+gjl9nhvuFIjw/GxlWGCOlsXf3zhvbUs0enj4Y5gqj8HR6 EsDo5KmtDaq03pVrX22+0EGPTPFRT10NByCTeYFpfPVVx0c8hAwmAOv2yAX4tBOB5xUHCKsfFsn ImIpngXS+9bcnCuE0a5yju0txBpd8v1ANNCdZq5LkLYMjNG1uvlpEWeY/LFfM1uMXjTtnzyFPQO HWLGUxJb6wlfjk5WGhgCp9PpEhhiurF9782e2pKhDmcl+KPISf7Ja/RnRe2MAlfk98Jq4GqUF4k jh0kMq59/gPa2mOA/6TZZ7QPrk3IPLmEkIhMk= X-Google-Smtp-Source: AGHT+IHWcY+GtYxvT2QkvWrdoG6nA29trQIRuLrsD8pNdWPYP/nxv4eW9O/LAvnZtRfQqFwuGVp1RA== X-Received: by 2002:a05:6a20:a109:b0:34f:c83b:b3f6 with SMTP id adf61e73a8af0-35ba2598aebmr8896833637.43.1763219398046; Sat, 15 Nov 2025 07:09:58 -0800 (PST) Received: from DESKTOP-8TIG9K0.localdomain ([119.28.20.50]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7b927d1c413sm8266986b3a.69.2025.11.15.07.09.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Nov 2025 07:09:57 -0800 (PST) From: Xie Yuanbin To: tglx@linutronix.de Cc: aalbersh@redhat.com, acme@kernel.org, adrian.hunter@intel.com, agordeev@linux.ibm.com, akpm@linux-foundation.org, alex@ghiti.fr, alexander.shishkin@linux.intel.com, andreas@gaisler.com, andrii@kernel.org, anna-maria@linutronix.de, aou@eecs.berkeley.edu, arnd@arndb.de, baolin.wang@linux.alibaba.com, borntraeger@linux.ibm.com, bp@alien8.de, brauner@kernel.org, bsegall@google.com, dave.hansen@linux.intel.com, davem@davemloft.net, david@kernel.org, david@redhat.com, dietmar.eggemann@arm.com, frederic@kernel.org, gor@linux.ibm.com, hca@linux.ibm.com, hpa@zytor.com, irogers@google.com, james.clark@linaro.org, jlayton@kernel.org, jolsa@kernel.org, juri.lelli@redhat.com, justinstitt@google.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux@armlinux.org.uk, llvm@lists.linux.dev, lorenzo.stoakes@oracle.com, luto@kernel.org, mark.rutland@arm.com, mathieu.desnoyers@efficios.com, max.kellermann@ionos.com, mgorman@suse.de, mhiramat@kernel.org, mingo@redhat.com, morbo@google.com, namhyung@kernel.org, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, nysal@linux.ibm.com, oleg@redhat.com, osalvador@suse.de, palmer@dabbelt.com, paulmck@kernel.org, peterz@infradead.org, pjw@kernel.org, qq570070308@gmail.com, riel@surriel.com, rostedt@goodmis.org, ryan.roberts@arm.com, segher@kernel.crashing.org, sforshee@kernel.org, sparclinux@vger.kernel.org, svens@linux.ibm.com, thuth@redhat.com, urezki@gmail.com, vincent.guittot@linaro.org, vschneid@redhat.com, will@kernel.org, x86@kernel.org Subject: Re: [PATCH v3 3/3] Make finish_task_switch and its subfuncs inline in context switching Date: Sat, 15 Nov 2025 23:09:28 +0800 Message-ID: <20251115150928.649-1-qq570070308@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <87346gbd04.ffs@tglx> References: <87346gbd04.ffs@tglx> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Fri, 14 Nov 2025 21:00:43 +0100, Thomas Gleixner wrote: > What are subfuncs? This is not a SMS service. Use proper words and not > made up abbreviations. > > Again you mark them __always_inline and not inline. Most of them are > already 'inline'. Can you please precise in your wording? > > This really can go into the comment section below the first '---' > separator. No point in having this in the change log. Thanks for pointing it out, I will improve it in v4 patch. >> After `finish_task_switch` is changed to an inline function, the number of >> calls to the subfunctions (called by `finish_task_switch`) increases in >> this translation unit due to the inline expansion of `finish_task_switch`. >> Due to compiler optimization strategies, these functions may transition >> from inline functions to non inline functions, which can actually lead to >> performance degradation. > > I'm having a hard time to understand this word salad. I think the description is very important here, because it explains why it needs to make the subfunctions as __always_inline. Where is difficult to understand specifically? Please point it out, and I will improve the description in v4 patch. Thank you very much! > What means (rdtsc)? This is a high-precision timestamp acquisition method in x86. The description here is not sufficient, thanks for pointing it out, I will improve it in v4 patch. > So the real benefit is observable when spectre_v2_user mitigations are > enabled. You completely fail to explain that. What kind of explanation is needed here? ```txt When spectre_v2_user mitigation is enabled, kernel is likely to preform branch prediction hardening inside switch_mm_irq_off, which can drastically increase the branch prediction misses in subsequently executed code. On x86, this mitigation is enabled conditionally by default, but on other architectures, for example arm32/aarch64, the mitigation may be fully enabled by default. `finish_task_switch` is right after `switch_mm_irq_off`, so makeing it inline can achieve high performance benefits. ``` Is it ok? Thanks very much! > bzImage size is completely irrelevant. What's interesting is how the > size of the actual function changes. I think the bzImage size is meaningful, at least for many embedded devices. Due to compression algorithms, code size cannot directly reflect to the compressed size. Anyway, I will supplement the size of the .text section in the v4 patch. Thanks very much! Xie Yuanbin