[net-next] net/core/dev.c: enable timestamp static key if CPU isolation is configured
Message ID | ZdeSHbRa3rtHE+2E@tpad |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-77144-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp135667dyb; Thu, 22 Feb 2024 10:39:58 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWmu2CRTXMAlSgBf2LnlLeiAu5pBZa/VAHPc4OvhGCIB3U5sGkBsQG3VHl8xWjFOGeP7teSgAD1KqMxbXkpd1icz4DpGg== X-Google-Smtp-Source: AGHT+IHbkQOulC2EipNSmuIeLdb+katyV5i2B0pAXAgb1hj2IrWozsHKr7anaF+8ZuS8oEbsb9Lk X-Received: by 2002:a17:906:d85:b0:a3f:9de3:59a8 with SMTP id m5-20020a1709060d8500b00a3f9de359a8mr1267666eji.1.1708627198167; Thu, 22 Feb 2024 10:39:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708627198; cv=pass; d=google.com; s=arc-20160816; b=rY9GLoOnfKR/a8AfZHIDvO4yHsn+3KkjPJdrX2vTmPl0EJb0M4ri/R/aBKRoCmYGq2 cLs/4a8/aRuYQfZfOvgULuWahWXjckatSapwcGyu0DvJX2z18JO+4f6ZHqujBAWshCsn ebr4MV3OSUFNS9Bw88V0iSVID6B4jrt/xpU8ufVaZHVzAZvjByQ3Qr+HOhC6YaBH1YcJ eJuXZAQIs7UOIGcQ56GyV5NR64odT0DjajezkvqciMZpBD05G3brmkqceF5awCEkC+X5 13WzFer1xAZ4/Xnr/LjvSYQvoG4G3J1bKx+KvlNnrF/sONx/IaIA2m92wnxSQpFoVtK/ Bsyg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=bvj8T6fBipY3xpufjhC25WSBfuxca3GiHOALi4Tt8m0=; fh=gwwalfy4YbUcYDGPvJIDKaPnuE2Bj6cwtaTBqcLFN2Q=; b=Ul9tLb37USIwLVYSTKRzq11qd+NZ7S5yXRXplPUUfV/4Gbcidrt7EVSND7/FJmokwK FV+O/0v9nOMZ0i30ZFGSYggiBaMllGAxznL/M2cz1DluZ1uk1FvoDB6PMuPbF5G7itkc 6afxj0kDzaVuYl5KPEf2r4HEGMEUyDlDO2xbjMgYLuLLbf+aBNFqrd+nz1RzBeOk1cNH R2byMyGCi/Xkm6qs9s97XQaj1trG4gCITT/0PeXrePh50MfoEpZOr/IqEqAeioDUblbr DSOSLLXM/ayIOC+3Uq+OOTFFikfE6lPbwKAhn44RN48ECU5oj6ldJNRarD0GKA8PN3/h kXxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=d1BfJQiR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-77144-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77144-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id sa13-20020a1709076d0d00b00a3d62fb274esi6014927ejc.249.2024.02.22.10.39.57 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 10:39:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-77144-ouuuleilei=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=@redhat.com header.s=mimecast20190719 header.b=d1BfJQiR; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-77144-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-77144-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 B3F7E1F27215 for <ouuuleilei@gmail.com>; Thu, 22 Feb 2024 18:39:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F4E0140378; Thu, 22 Feb 2024 18:29:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="d1BfJQiR" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 197B7137923 for <linux-kernel@vger.kernel.org>; Thu, 22 Feb 2024 18:29:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708626555; cv=none; b=cEKVmv45NV7KVE+umKItjGjUzRrtLBZ3S73H7/tw0mqfWVjW6MFzOTepJtED4hsY5FVPqV1Blvd5YlWbIAVU3Nbh2L5hc5rjIo412HtRdTvz75uohsYpMlYqGj0xLb/jW5AXgITFXwxQZQCVE9fFchLEZiyYD0NW94GPrw5tbgs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708626555; c=relaxed/simple; bh=/wOS2SUpgSsEw/ISAn+302Uf7UW8Yp6RwMhfod64tJ8=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=ROn4rbKTinJCqmwSu7S4LJrEDPUt32j98JTYTE4Fl2NTEDGQKIQNrvoSh+gaRHSbe6XNlk/cZlzhh6OkgzifJrnGZgH8TUEfOVsQFunlw4uh44mFQIhPAUs6CyJ24JEVR+ikCeF4NPEpOIfH/ckBrHvi9/P4yN5e3ebR9XI4dkM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=d1BfJQiR; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708626553; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=bvj8T6fBipY3xpufjhC25WSBfuxca3GiHOALi4Tt8m0=; b=d1BfJQiR7Lcgoyn3/Bde+LnP19d1wKn5+7LVzEpMWJPIVJ7N51GmiaLdmABQpi7fl/Erb5 +J9ou+dUUDNAflfXnwmZ8uiG2mvD9AXp0l671VLQzPgbp7zE352eE6OsDaVF0mBpDwum2J jKyYnD4ryUmdM0yyVdOGHp4Ml3nTYCA= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-H1RAiGg0N6q0UzIEJeJIww-1; Thu, 22 Feb 2024 13:29:09 -0500 X-MC-Unique: H1RAiGg0N6q0UzIEJeJIww-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3A3A5106D039; Thu, 22 Feb 2024 18:29:09 +0000 (UTC) Received: from tpad.localdomain (unknown [10.96.133.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06861492BC8; Thu, 22 Feb 2024 18:29:09 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 762B5401344BE; Thu, 22 Feb 2024 15:27:41 -0300 (-03) Date: Thu, 22 Feb 2024 15:27:41 -0300 From: Marcelo Tosatti <mtosatti@redhat.com> To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Jakub Kicinski <kuba@kernel.org>, Eric Dumazet <edumazet@google.com>, Frederic Weisbecker <frederic@kernel.org>, Valentin Schneider <vschneid@redhat.com>, Paolo Abeni <pabeni@redhat.com> Subject: [PATCH net-next] net/core/dev.c: enable timestamp static key if CPU isolation is configured Message-ID: <ZdeSHbRa3rtHE+2E@tpad> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791413835220582064 X-GMAIL-MSGID: 1791625472860293155 |
Series |
[net-next] net/core/dev.c: enable timestamp static key if CPU isolation is configured
|
|
Commit Message
Marcelo Tosatti
Feb. 22, 2024, 6:27 p.m. UTC
For systems that use CPU isolation (via nohz_full), creating or destroying
a socket with timestamping (SOF_TIMESTAMPING_OPT_TX_SWHW) might cause a
static key to be enabled/disabled. This in turn causes undesired
IPIs to isolated CPUs.
So enable the static key unconditionally, if CPU isolation is enabled,
thus avoiding the IPIs.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Comments
Hi, On Thu, 2024-02-22 at 15:27 -0300, Marcelo Tosatti wrote: > For systems that use CPU isolation (via nohz_full), creating or destroying > a socket with timestamping (SOF_TIMESTAMPING_OPT_TX_SWHW) might cause a > static key to be enabled/disabled. This in turn causes undesired > IPIs to isolated CPUs. I believe Willem is correct, the relevant flag is SOF_TIMESTAMPING_RX_SOFTWARE, see: https://elixir.bootlin.com/linux/v6.8-rc5/source/net/core/sock.c#L938 the example you used is a sort of API misuse, placing flag where a bool is expected. Please send a v2 with the updated commit message, you can mention both SO_TIMESTAMPING (SOF_TIMESTAMPING_RX_SOFTWARE) and SO_TIMESTAMP. Please also include Willem in recipients list, since he gave feedback on previous version. Thanks! Paolo
diff --git a/net/core/dev.c b/net/core/dev.c index c588808be77f..15a32f5900e6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -155,6 +155,7 @@ #include <net/netdev_rx_queue.h> #include <net/page_pool/types.h> #include <net/page_pool/helpers.h> +#include <linux/sched/isolation.h> #include "dev.h" #include "net-sysfs.h" @@ -11851,3 +11852,14 @@ static int __init net_dev_init(void) } subsys_initcall(net_dev_init); + +static int __init net_dev_late_init(void) +{ + /* avoid static key IPIs to isolated CPUs */ + if (housekeeping_enabled(HK_TYPE_MISC)) + net_enable_timestamp(); + + return 0; +} + +late_initcall(net_dev_late_init);