Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp650397pxh; Wed, 10 Nov 2021 07:24:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyZF6GNV4yUwaPHESkY6Qxtl9ODQ7yzpXOvP9qq7inJRWRRAx2GGEXJtqPLcYDSSjAknGB X-Received: by 2002:a17:902:a417:b0:13f:b33f:a632 with SMTP id p23-20020a170902a41700b0013fb33fa632mr16653888plq.71.1636557879560; Wed, 10 Nov 2021 07:24:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636557879; cv=none; d=google.com; s=arc-20160816; b=i4uNSG9FCA4rc9uGkDFqYIjHYDCyyiP5JyZ1PKvhTbPjZKR+TP4VuNikJLkOiNdjL1 0Jr6huaRo+5QXfK8O1xxNsLLvCZIfjKghQ+Icft/FiJMQ47kJDvxNiyGTh5mkHI9j9iR TENGQ+8gMtzfu7Vp2yf6/d6SNoP0Q2J+3ok0Tny0TRK0f351prJgnP36DWdxIJk85Wjv SC8vsP+56ShJddapfk/xL1ULHrUEbKQUzWWeG/3GiR/bNlfq10DVgoYcY6yTGTiEO1pU OVBCL1c4o8QIWIoNGuS5fjnag4Qzju9lb5Wx26H1hGv3PEMsvbY60mTGlSXlWZuwgzYf pZ8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PVisaRti7NFa9yhvUdiqXQvmi2dDDWJNlCuijgPtngA=; b=c3Pm8s0pH3uP+RD6U2+2rE8zFH6jvX9xYmkcSbgwnSoQ3HpexHwiAj8uyiysx60Dv2 loLkQLdgfwMdzCNczo82helcHTgIkk1GFcoVXJp8pD5byDwuO19Jbtj6miyzCSP/hDtn 98PBF0lYJ3xTS6Q1QNDMhtOXw0DdFkXAP9dgvYM3FMvkRAWDNe3+uI0+MD2DZVxq+imY 0UlKDEn3ZL5IYllTLHtWiot9NLYmiva9pw+NzLIHKdFqFcg99HBXpwG+9hyFoWcjJ2Hr WF7fwTbSvODqJmtbr6dCAkgheIXYFDBDRzKPoPFHw10Bnzx8JfwP6GrgVzL5mPZZ1997 Dg/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=mYm26Ogg; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x69si84915pgd.420.2021.11.10.07.24.25; Wed, 10 Nov 2021 07:24:39 -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=@google.com header.s=20210112 header.b=mYm26Ogg; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232317AbhKJPZk (ORCPT + 99 others); Wed, 10 Nov 2021 10:25:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54808 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231148AbhKJPZk (ORCPT ); Wed, 10 Nov 2021 10:25:40 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53603C061764 for ; Wed, 10 Nov 2021 07:22:52 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id o29so2555317wms.2 for ; Wed, 10 Nov 2021 07:22:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=PVisaRti7NFa9yhvUdiqXQvmi2dDDWJNlCuijgPtngA=; b=mYm26OggpdJRF+3j/ObGMOoEn8buavasWLX608adsfYeSCQSiodm6+kv89jqVAjYcT EOPuC0gZoSHe2qeT7xMh8aU4Qe5fuPn3nrQojMkLFbshOKMuhM9t0wug2XwwzDrwtIBk 28A//MMVtzwSOv2QbrmgAO/2nI7v7CMscH01Y/z9+P6h0mFALc0pN9L3Yx2ki+vVH0tv IccsLTET77RRPmOaXIxM9vRcysdLWLChrBbpc+rxU0+9qFCVzFVL9mzIU9ybHevANoxB QhhIB+oJ1ElAG3/2FyXPAPYj39fVOgJD8DF9BoPCBv1Db76V064w5Tw5oC6I22e/ICAc Jc9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=PVisaRti7NFa9yhvUdiqXQvmi2dDDWJNlCuijgPtngA=; b=IifSRznwYppFae38Q29/04vrJHQ4BGkdcfp2jo3QU4WYo30So+3hCDD8vPXQKdPxCK VNrC8VTdEXVG488VhZztPqS8eqGxyR00KU9RdKMUujQRlNSI57MkUkrAzwMwvLti0dkq AvMS87zbTLr9gkCibQkNt9Rgz0LtnUogImnl4hx0cchB7BCJzDj1Y2eClFUgRqtysG05 PbIuu2/zjewzu/bhA3fbKAY5BcKRlZQMXRn0K9XUQMn3+Xx6c3A62Ns7NL9BHxyZ9WfA L+U980vNUUABac5i5EAjMb8A3VD58GYPI/e/DI6WuIZDcOZd8ltAJ6Kb01yPtSil6G/b /Tpg== X-Gm-Message-State: AOAM531k/Mt3Y4AtIkN5FoCzTMpK+BtEsYrWJRLgiPouyA4slcOi6mmc 50Ax1dUebF3XZYZqqRmWxosT4CvoNj15sRlnzcSyBg== X-Received: by 2002:a05:600c:1f13:: with SMTP id bd19mr1236688wmb.9.1636557770583; Wed, 10 Nov 2021 07:22:50 -0800 (PST) MIME-Version: 1.0 References: <20211110010906.1923210-1-eric.dumazet@gmail.com> <20211110010906.1923210-3-eric.dumazet@gmail.com> In-Reply-To: From: Eric Dumazet Date: Wed, 10 Nov 2021 07:22:37 -0800 Message-ID: Subject: Re: [PATCH 2/2] jump_label: refine placement of static_keys To: Ard Biesheuvel Cc: Peter Zijlstra , Eric Dumazet , linux-kernel , Josh Poimboeuf , Jason Baron , "Steven Rostedt (VMware)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Nov 10, 2021 at 2:24 AM Ard Biesheuvel wrote: > > On Wed, 10 Nov 2021 at 09:36, Peter Zijlstra wrote: > > > > On Tue, Nov 09, 2021 at 05:09:06PM -0800, Eric Dumazet wrote: > > > From: Eric Dumazet > > > > > > With CONFIG_JUMP_LABEL=y, "struct static_key" content is only > > > used for the control path. > > > > > > Marking them __read_mostly is only needed when CONFIG_JUMP_LABEL=n. > > > Otherwise we place them out of the way to increase data locality. > > > > > > This patch adds __static_key to centralize this new policy. > > > > > > Signed-off-by: Eric Dumazet > > > --- > > > arch/x86/kvm/lapic.c | 4 ++-- > > > arch/x86/kvm/x86.c | 2 +- > > > include/linux/jump_label.h | 25 +++++++++++++++++-------- > > > kernel/events/core.c | 2 +- > > > kernel/sched/fair.c | 2 +- > > > net/core/dev.c | 8 ++++---- > > > net/netfilter/core.c | 2 +- > > > net/netfilter/x_tables.c | 2 +- > > > 8 files changed, 28 insertions(+), 19 deletions(-) > > > > > > > Hurmph, it's a bit cumbersome to always have to add this __static_key > > attribute to every definition, and in fact you seem to have missed some. > > > > Would something like: > > > > typedef struct static_key __static_key static_key_t; > > > > work? I forever seem to forget the exact things you can make a typedef > > do :/ > > No, that doesn't work. Section placement is an attribute of the symbol > not of its type. So we'll need to macro'ify this. Yes, this is also why I chose a short __static_key (initially I was using something more descriptive but longer) > > But I'm not sure I understand why we need different policies here. > Static keys are inherently __read_mostly (unless they are not writable > to begin with), so keeping them all together in one place in the > binary should be sufficient, no? It is not optimal for CONFIG_JUMP_LABEL=n cases. For instance, networking will prefer having rps_needed / rfs_needed in the same cache lines than other hot read_mostly stuff, instead of being far away in other locations. ffffffff830e0f80 D dev_weight_tx_bias ffffffff830e0f84 D dev_rx_weight ffffffff830e0f88 D dev_tx_weight ffffffff830e0f8c D gro_normal_batch ffffffff830e0f90 D rps_sock_flow_table ffffffff830e0f98 D rps_cpu_mask ffffffff830e0f9c D rps_needed ffffffff830e0fa0 D rfs_needed ffffffff830e0fa4 D netdev_flow_limit_table_len ffffffff830e0fa8 d netif_napi_add.__print_once ffffffff830e0fac D netdev_unregister_timeout_secs ffffffff830e0fb0 D ptype_base When CONFIG_JUMP_LABEL=y, rps_needed/xps_needed being in a remote location is a win because it 'saves' 32 bytes than can be used better