Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp663770lqs; Fri, 14 Jun 2024 01:40:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUf2PrrGtvImknNPGOJ3zzjo1Sv3jwtsQ9dfrsesJpTUFhKjleVwW8ISNY3YzskDuibr8vu2Mw4BaBaGKiHYqFWcVVMnnJosvFizFcbZQ== X-Google-Smtp-Source: AGHT+IGTf2ic3w9uezPUBPla8+ck4BcHEp9N3NOxqO62FYlehpzQtWGbfhDu6N4f61HYLTFYsHkY X-Received: by 2002:a05:6122:20a5:b0:4eb:5d5b:a894 with SMTP id 71dfb90a1353d-4ee3e291ec4mr2392798e0c.6.1718354451144; Fri, 14 Jun 2024 01:40:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718354451; cv=pass; d=google.com; s=arc-20160816; b=A9VvL5EiEIoqHQnEdn5s1U37sfvZ/6xTQdaYznMr5nQ9SqGKSH1fy3AhrB3kOgsmIm in8+K8snymzXh6gbE8gM4PjteYIq6ryBfp1s0PYUKYucMl2OKP5ZNumnp8QxHyRUgPsq vlB0PYJ3TAJBSXrWEfZmi9KsKkSACMqo25mnGxjc9gBdLKP032KZfA+JKdr4SMZV0WXX NofPvWBACZvXSXqvxaqymjL7T/qVmCMdnqniZHNXaJUBQdMhBfyzNQ89WDKvspLkE+BF Q9JIM9G9THL6cOcz1ZGp66wJVKFeDFFxdJ6y/aD7CdTxzRaVRhiFNjc6tL5Y39gjnHnm K+UQ== 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=c+HO6rpfLBrq4Z9yOBu/M6P73t6c6818voOiVXvjIvw=; fh=SgWHRcrWXwPXfka8Mu75B5YsSsAtWHBapimHcWKQTmA=; b=igdO3jEJnRJeLaQGaFuSlhwG8he4+kLCJPLGggKNhYKOv6iyO0opjcLSGArn4vex1s bBXrO/Ad0w7pd685flWaBUzIT3e336IIDqhd28eHawMVCUwglSpNk9LbcNfDKuFA8vz8 +uJmV/92rrfqZCTDGvCEcN2QVubj90qI0R6SkqIFPT5AvYZSK+vexEquDhibxrG3rNHL vq+vIbbSrBWQzlhNubkHBXVn1Is9IBRvZUROHsJi5rm7mZdzAJnOqwTBLqUg3QYtrMGL pNCoAzN5oSu/2oV/mLApuKl+WrXDoDz4zej1wIqGg862sq4dA7Jg/uXhu/s2lPsilyA8 7VXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="nWwE/M0O"; 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-214566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214566-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. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-441f2fc6150si32291571cf.499.2024.06.14.01.40.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 01:40:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="nWwE/M0O"; 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-214566-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214566-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 9DF521C24F1E for ; Fri, 14 Jun 2024 08:39:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37E84191483; Fri, 14 Jun 2024 08:38:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="nWwE/M0O" Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.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 A7043190076 for ; Fri, 14 Jun 2024 08:38:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718354310; cv=none; b=Rg9vpKyQ7Mwtmu5z879EtE0M6ytlaLdSWcRuZIBjFUNhHTsHlV83g9TOW3x4lGBCgEKu3bfNt9tIQMIg4fkEXmbKRbzPJkI9N3Sv9UjWwq1FmvcIaNmNeYqCwzlPqxsuaEIDe+21f74ekjkNYmOYQiDC5VZRZw7xahiUrzDeQPs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718354310; c=relaxed/simple; bh=c+HO6rpfLBrq4Z9yOBu/M6P73t6c6818voOiVXvjIvw=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=IAvuTe3gTfbRZzfKVEoA5D4xt0Cbjagab+hKYB6kcdCUjtzn/72vUqIGpP0X4Aca1wM5cWV8t2Zwy9LoVb2U/4bwYywg7C6wmdbFtPhs2QwpS24Zhh8L/k6iG6wDIwOyUdwb8NdRWmEROZ5MWR17QgPgVcduL3eREOWHS99VMYE= 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=nWwE/M0O; arc=none smtp.client-ip=209.85.208.41 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-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-57a16f4b8bfso11670a12.0 for ; Fri, 14 Jun 2024 01:38:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1718354307; x=1718959107; 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=c+HO6rpfLBrq4Z9yOBu/M6P73t6c6818voOiVXvjIvw=; b=nWwE/M0O0gq5uplzuekjg8J8iE2rhreU+wjM7Hjp7X3pv4LmE4j3CP7BZiO/IF20GT 80KEaHqMR/ams+VbM1aTX5tbZt1Rdc0hSsDa1d7BBRw94Df9kOruep7F6JWfID8lela6 F7UrV5n+i1QjfH8WaeVoMztQoxVJF+7rMOCn7WIWlgxBLKvg2Fu/UtTq5xHhJDsG4U0c mCMSOrTX4P12oYhn2PXzFE7annnfucupBbnRC1kxtqvVHtlko3xJrGVp3Cjk3ylTRo1a FZDP+/gtSMe0pZhs/rEKLzNIuyAWmEYqgdML0/dkm9HoMGMAsv1euriOdJO6nGq2wojD 012g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718354307; x=1718959107; 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=c+HO6rpfLBrq4Z9yOBu/M6P73t6c6818voOiVXvjIvw=; b=ZmAuFj8ei5mwV/lZ9ADaESYMqP694+foEjJ4gAmD/53OcGLHygsHcolN8hCeC+zTX2 4h9XWUNVjIqfYmyuvgu9aug6qV3VlAB3NnsjuJepDmTzVVEbWz4ImEKm1hAwLBV6BeKd 9lMmEXeHEPjCyEFdd1QBiZGx/Ihr/xm4Ypsk9OwkbZQNdphy/jP5z6BaomIc9UB18Ews Wk6JX7O8BdYCsGoq+ZMQyKD39489uNtb9ab7ajyuDk4Cczs0wM51zPdCEFQtcnfiYsEM TPTA49IxgC1QgFTT3CLlbXeGsATDtD+H9m4gqCfuHeNhuRhJZ+V0GmOleJQx1Z42Zkhi Dp9Q== X-Forwarded-Encrypted: i=1; AJvYcCWQKLaSkxtMsF8b9H4nNkleATk/cMb8om8rzUzPArgsj0AfK2WrPc1vBGPgYcFZCKNBM0z6mhAu+hPG7rL0Z5/s8+mqBqq8ipV/VGs+ X-Gm-Message-State: AOJu0YzFY09A/W8sgM1uvFTZ6z8Jpl0mw6ttSX10rULLl86FzDd032yy HJx9WGqan1/iBHI7QRwLzezrmfsLKGL3Y5Fh3AP1jwi/KSfTJcdYYATIh0/6bVtX2ykiZPyrQ07 zk4cCSM9HGYoaeZXes2NI+RU+V99SMHMAul+E X-Received: by 2002:a05:6402:35d1:b0:57c:b712:47b5 with SMTP id 4fb4d7f45d1cf-57cbed0de04mr171811a12.4.1718354306227; Fri, 14 Jun 2024 01:38:26 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240612170303.3896084-1-bigeasy@linutronix.de> <20240612170303.3896084-9-bigeasy@linutronix.de> <20240612131829.2e33ca71@rorschach.local.home> <20240614082758.6pSMV3aq@linutronix.de> In-Reply-To: <20240614082758.6pSMV3aq@linutronix.de> From: Eric Dumazet Date: Fri, 14 Jun 2024 10:38:15 +0200 Message-ID: Subject: Re: [PATCH v6 net-next 08/15] net: softnet_data: Make xmit.recursion per task. To: Sebastian Andrzej Siewior Cc: Steven Rostedt , linux-kernel@vger.kernel.org, netdev@vger.kernel.org, "David S. Miller" , Daniel Bristot de Oliveira , Boqun Feng , Daniel Borkmann , Frederic Weisbecker , Ingo Molnar , Jakub Kicinski , Paolo Abeni , Peter Zijlstra , Thomas Gleixner , Waiman Long , Will Deacon , Ben Segall , Daniel Bristot de Oliveira , Dietmar Eggemann , Juri Lelli , Mel Gorman , Valentin Schneider , Vincent Guittot Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Fri, Jun 14, 2024 at 10:28=E2=80=AFAM Sebastian Andrzej Siewior wrote: > > On 2024-06-12 13:18:29 [-0400], Steven Rostedt wrote: > > On Wed, 12 Jun 2024 18:44:34 +0200 > > Sebastian Andrzej Siewior wrote: > > > > > Softirq is preemptible on PREEMPT_RT. Without a per-CPU lock in > > > local_bh_disable() there is no guarantee that only one device is > > > transmitting at a time. > > > With preemption and multiple senders it is possible that the per-CPU > > > recursion counter gets incremented by different threads and exceeds > > > XMIT_RECURSION_LIMIT leading to a false positive recursion alert. > > > > > > Instead of adding a lock to protect the per-CPU variable it is simple= r > > > to make the counter per-task. Sending and receiving skbs happens alwa= ys > > > in thread context anyway. > > > > > > Having a lock to protected the per-CPU counter would block/ serialize= two > > > sending threads needlessly. It would also require a recursive lock to > > > ensure that the owner can increment the counter further. > > > > > > Make the recursion counter a task_struct member on PREEMPT_RT. > > > > I'm curious to what would be the harm to using a per_task counter > > instead of per_cpu outside of PREEMPT_RT. That way, we wouldn't have to > > have the #ifdef. > > There should be a hole on !RT, too so we shouldn't gain weight. The > limit is set to 8 so an u8 would be enough. The counter is only accessed > with BH-disabled so it will be used only in one context since it can't > schedule(). > > I think it should work fine. netdev folks, you want me to remove that > ifdef and use a per-Task counter unconditionally? It depends if this adds another cache line miss/dirtying or not. What about other fields from softnet_data.xmit ?