Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp2806976lqo; Mon, 20 May 2024 18:52:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVHzIwWCF2DSet5LvZuV/n1FFKb4B+E9T0A7R4naDa1UVBI9FqBVjz4WTSUjolIhW7rcZdKoC1ZDiZOi/esLUouVehBPQgr3/s+547tsQ== X-Google-Smtp-Source: AGHT+IHnSqr5ReLS+KO7/fPBT8i/1fdrEgLAjHflc4lb1gqFdx3Cpx8zCi4ZAxc7FWFtviTgd8b3 X-Received: by 2002:a05:600c:1f90:b0:416:8efd:1645 with SMTP id 5b1f17b1804b1-41fea93a030mr274891685e9.7.1716256378984; Mon, 20 May 2024 18:52:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716256378; cv=pass; d=google.com; s=arc-20160816; b=eXiaKpXzFrisdQnHhPaG7uhG9r42e1MKngfgXiUmnMC7bpsUXuoeghN7kF4UiQGOit J1QhVQt0lPJgOK3Jy9Ij3TJVyZ4OJyBHWDO29n8ToXj8T+FgD1wKxbXi/A9Bn30QawA8 WytM5ncDdC3AdSCn8xcTUUZnqREmWXTRbgxvrLYJtujq1AmfpwcBe5X2C/ry3T/wDSja JyRDW+d3eWfFOydF8W4bbxQLEmyOGLTeyqw1UytoD4KcsfLMJGMGqzTpbT8ynYPd5/CG zz4tgPS8Sw7w3CQc9kKgI6Tr7+buFEyOth8hHdg3eYcSJ9LtgQz0V/Cy2ga0DOAKb8pm zHug== 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=ePtZldgSJpBB0VdXgkJqxbFpcqfbGSYwOlaG2fUCcJA=; fh=HM6ZdGHC9UsHmDx9jRefsTgWSMVBB6ettBNjKGDlh1c=; b=aLdh38hf4i0YKm4gZOJtRS1HKZ8r+zyBEofOqb4qoBUVISPJzXlhjq6P6C0ueEzUGD BHCpREOAT1Z1Q38XBTBOklalBSH6aZiNRILePBZL92jstovZ6x6T824pow4A8MiFozNY c2tEPDgUUYN4uBmpFQeD8mQd7ekGOcoLHwnJAE3Q5vtzetCsxoRALubsgqv8kwVaCDwq Sn1TBFnMTv4rGVymWf7oAkcD+8BVpOCNOmcUSjfKGpKGF/U5zcQP4utz+UJjXFfIDIMM 617a0Ilgh0tGFURRzOPsTefW8cpUON+Mif9h8CK61vFl1AS8Rn/fAU9dXbjjWTvpZ9Hq HC6A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=O89gPZ2F; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-184354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id a640c23a62f3a-a5cdc248f30si632172366b.838.2024.05.20.18.52.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 May 2024 18:52:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-184354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=O89gPZ2F; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-184354-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-184354-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id B4D8E1F21BD1 for ; Tue, 21 May 2024 01:52:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A420F134A9; Tue, 21 May 2024 01:52:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O89gPZ2F" Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (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 48AD5848A; Tue, 21 May 2024 01:52:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716256364; cv=none; b=n2pj+Gj6SELDuEw24Gzp2d+iyEXty0Ivw9ioXc+0D5rbCRIvpFTmB2R7QVDYXYEdwOxcJBsbJwVxyomBvDJmoCYmeRmKDoMe1zZ+SZkVJJxIEuqFmi6h/AqovPTZ8nuhhH9zdVO0eWS2HYkt0C+wkX3iYJ/cVDXK6kYVXa1cOPQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716256364; c=relaxed/simple; bh=ufxSg3xyf/Gj6U1EQfafcgtdoMatyKkEh7vkXarvHUc=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Od3qkjI2/PIomRm2a9VTeFZMNbFmVZO3vvqfpGNywWMSq1c+9HMKcK/RQ+tsnV8R9OCZPd2iqJurK5chJNbu4etr+p009QYuXVtMpOgsJIjpozNk0FpRJghN622SbghL8WLflmMkvvnxFpRjgyF8v+gJtWgViOJEWN1WBQ8qZbo= 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=O89gPZ2F; arc=none smtp.client-ip=209.85.128.50 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 Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-420298ff5b1so37073805e9.1; Mon, 20 May 2024 18:52:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716256361; x=1716861161; 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=ePtZldgSJpBB0VdXgkJqxbFpcqfbGSYwOlaG2fUCcJA=; b=O89gPZ2F3WyRYgxF0gTklyHiai03R/aQ0BXPAsCO0VRoNvd5hfFCLYTifs4h7V1w+y y33zX1kxgCgoUoI4lE0H8A4I0hJJvl8JnM2nt6ecw0hY0p5pS3qRxa9Tf8PQEg8+wHXX Am2CFuU5eKoqwvUWBeI/wpBzztL1PROLPZfeo1fLhWt64QNvzXpZuxo7nX9jf218hb1f v/ZAIENxn/qJgR1Xcda8z7G3C90BPbvLcJwBYGG4lt15gasL1QEZ+LWfrbBUg6ZDwT1T oICPkkAjZrU2T8a9yvB7+z1iEoyJohmUj0UT4Zisa12Vbtb5G1pcNpVrqQFcsEymbCXM Ou2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716256361; x=1716861161; 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=ePtZldgSJpBB0VdXgkJqxbFpcqfbGSYwOlaG2fUCcJA=; b=XHxTHCKPYwnk5kokG4ko2TNO6AkiJiWkIkncw3cPntUCOkRbNJFKlRtHujq7PpKqe4 7t9b1ka/Cwu7CcpVJesNy/ITnpRAWDz+j3/RKin/ubwcPhulDin1trUdAmHg246PuCKo FMF//3MmKQAN8nBQ7feNdmg20GGmydLwWIoLM5sKyaVYZU1vFvlBphEgHTjjLntcYli2 c9DG53L4YVgIVMAuFRI4ZFxqfq4KMKHbwEU8ix6V8xqgJVqQ70cItmvWJNs8laubEuHI Xm1bTwJBg4QtPM0MowDyikOXwt24QXJlm8qUASI64nSSBLGGPrIQWV/0rUQeG4IdkQrV fhOg== X-Forwarded-Encrypted: i=1; AJvYcCXsXcCVYOnXtueJWynp6EP0KSxeyQnD3K6vCT8I1iFRVsS/zpoqX6po3jX2wl2QVk5hJsS3aD92/C3eRdfzGqldxDfTZmm/o1cORClJWYAMeIMYYF52yCKbSsSvfu/zkQocY/bPVMqOMP1+1rqC2smnnmvvYQO/tB9n X-Gm-Message-State: AOJu0YzH7x9xeZdLtLWjkFeuZu2KYeu8CQpEh7Qeqe48GJnvoENDsyg2 cAWbCIQPBWvvONCJphsCFtFf65sbVPGhnAo8ImvkEQfYuVjel8t+2qK2TBTtWOQA3bF7Fcq/iA2 ptupmZiRYjh39pqUMMpP6DPP5o68= X-Received: by 2002:a05:600c:5601:b0:41a:adc3:f777 with SMTP id 5b1f17b1804b1-41feaa38ec7mr304760275e9.16.1716256361431; Mon, 20 May 2024 18:52:41 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240503182957.1042122-1-bigeasy@linutronix.de> <20240503182957.1042122-15-bigeasy@linutronix.de> <87y18mohhp.fsf@toke.dk> <20240507123636.cTnT7TvU@linutronix.de> <93062ce7-8dfa-48a9-a4ad-24c5a3993b41@kernel.org> <20240510162121.f-tvqcyf@linutronix.de> <87le4cd2ws.fsf@toke.dk> <20240515134326.14x755Wb@linutronix.de> In-Reply-To: <20240515134326.14x755Wb@linutronix.de> From: Alexei Starovoitov Date: Mon, 20 May 2024 18:52:30 -0700 Message-ID: Subject: Re: [PATCH net-next 14/15 v2] net: Reference bpf_redirect_info via task_struct on PREEMPT_RT. To: Sebastian Andrzej Siewior Cc: =?UTF-8?B?VG9rZSBIw7hpbGFuZC1Kw7hyZ2Vuc2Vu?= , Jesper Dangaard Brouer , LKML , Network Development , "David S. Miller" , Boqun Feng , Daniel Borkmann , Eric Dumazet , Frederic Weisbecker , Ingo Molnar , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , Alexei Starovoitov , Andrii Nakryiko , Eduard Zingerman , Hao Luo , Jiri Olsa , John Fastabend , KP Singh , Martin KaFai Lau , Song Liu , Stanislav Fomichev , Yonghong Song , bpf Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 15, 2024 at 6:43=E2=80=AFAM Sebastian Andrzej Siewior wrote: > > On 2024-05-14 13:54:43 [+0200], Toke H=C3=B8iland-J=C3=B8rgensen wrote: > > > --- a/include/linux/sched.h > > > +++ b/include/linux/sched.h > > > @@ -1504,6 +1505,8 @@ struct task_struct { > > > /* Used for BPF run context */ > > > struct bpf_run_ctx *bpf_ctx; > > > #endif > > > + /* Used by BPF for per-TASK xdp storage */ > > > + struct bpf_net_context *bpf_net_context; > > > > Okay, so if we are going the route of always putting this in 'current', > > why not just embed the whole struct bpf_net_context inside task_struct, > > instead of mucking about with the stack-allocated structures and > > setting/clearing of pointers? > > The whole struct bpf_net_context has 112 bytes. task_struct has 12352 > bytes in my debug-config or 7296 bytes with defconfig on x86-64. Adding > it unconditionally would grow task_struct by ~1% but it would make > things way easier: The NULL case goes away, the assignment and cleanup > goes away, the INIT_LIST_HEAD can be moved to fork(). If the size > increase is not an issue then why not. Let me prepare=E2=80=A6 I think 112 bytes or whatever the size of bpf_net_context is a bit too much to consume in task_struct. Yes, it's big, but there are systems with 1m threads. 112Mbyte is not that small. bpf_net_ctx_set/get are not in critical path and get_ri will be inlined without any conditionals, so performance should be the same.