From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mail.toke.dk (Postfix) with ESMTPS id 3C77D982D65 for ; Tue, 28 Jun 2022 21:49:38 +0200 (CEST) Authentication-Results: mail.toke.dk; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.a=rsa-sha256 header.s=Intel header.b=GvQwJd8W DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656445778; x=1687981778; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=rckiSPr5+wxzNkTahHMP+SEYFlLnWpiNQnrV9iaYFnc=; b=GvQwJd8WtdNocgs5HUxuEQwMWbvUM1c9sKPtWZxpe4SmWgrtRXZwEVjj ZAGaXPl21QOc9muN3xkbX8R1aYM+z8ih4NdpXtnnLpjAGWuvy6P3qspZB heHqsSJhnFXPQ9Wl1D9ysFoA+2qbH3Xw3GE0a2vULAREXWZYSVXjAIG3y OncxhJ1/hPsHZq/6u0B55kSc+CBcnXMmQGRk5g83KiGLda3FhfQaCOUHS Bf/Ct5fkXX/ZFgGE3B91ZopYLk1FIzrRXBJPQiF6F6hRFRlHMlrrkjQHe z+Bb22F1oFscTaoB8aA3Ilr3JTD0KWyueATiGPcSGbdeLbN+7KzuoJwQu Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10392"; a="270595982" X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="270595982" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 12:49:31 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,229,1650956400"; d="scan'208";a="767288113" Received: from irvmail001.ir.intel.com ([10.43.11.63]) by orsmga005.jf.intel.com with ESMTP; 28 Jun 2022 12:49:26 -0700 Received: from newjersey.igk.intel.com (newjersey.igk.intel.com [10.102.20.203]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id 25SJmr9N022013; Tue, 28 Jun 2022 20:49:24 +0100 From: Alexander Lobakin To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Date: Tue, 28 Jun 2022 21:47:43 +0200 Message-Id: <20220628194812.1453059-24-alexandr.lobakin@intel.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220628194812.1453059-1-alexandr.lobakin@intel.com> References: <20220628194812.1453059-1-alexandr.lobakin@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: PSUSNYZFUWYUW7WJVPQLPRCICUQJHJKF X-Message-ID-Hash: PSUSNYZFUWYUW7WJVPQLPRCICUQJHJKF X-MailFrom: alexandr.lobakin@intel.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Alexander Lobakin , Larysa Zaremba , Michal Swiatkowski , Jesper Dangaard Brouer , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Magnus Karlsson , Maciej Fijalkowski , Jonathan Lemon , Toke Hoiland-Jorgensen , Lorenzo Bianconi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jesse Brandeburg , John Fastabend , Yajun Deng , Willem de Bruijn , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, xdp-hints@xdp-project.net X-Mailman-Version: 3.3.5 Precedence: list Subject: [xdp-hints] [PATCH RFC bpf-next 23/52] net, skbuff: constify the @skb argument of skb_hwtstamps() List-Id: XDP hardware hints design discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The @skb argument only dereferences the &skb_shared_info pointer, so it doesn't need a writable pointer. Constify it to be able to pass const pointers to the code which uses this function and give the compilers a little more room for optimization. As an example, constify the @skb argument of tpacket_get_timestamp() and __packet_set_timestamp() of the AF_PACKET core code. There are lot more places in the kernel where the similar micro-opts can be done in the future. Signed-off-by: Alexander Lobakin --- include/linux/skbuff.h | 3 ++- net/packet/af_packet.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index 1c308511acbb..0a95f753c1d9 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1617,7 +1617,8 @@ int skb_zerocopy_iter_stream(struct sock *sk, struct sk_buff *skb, /* Internal */ #define skb_shinfo(SKB) ((struct skb_shared_info *)(skb_end_pointer(SKB))) -static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb) +static inline struct skb_shared_hwtstamps * +skb_hwtstamps(const struct sk_buff *skb) { return &skb_shinfo(skb)->hwtstamps; } diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index d08c4728523b..20eac049e69e 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -449,10 +449,10 @@ static int __packet_get_status(const struct packet_sock *po, void *frame) } } -static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts, - unsigned int flags) +static __u32 tpacket_get_timestamp(const struct sk_buff *skb, + struct timespec64 *ts, unsigned int flags) { - struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); + const struct skb_shared_hwtstamps *shhwtstamps = skb_hwtstamps(skb); if (shhwtstamps && (flags & SOF_TIMESTAMPING_RAW_HARDWARE) && @@ -467,7 +467,7 @@ static __u32 tpacket_get_timestamp(struct sk_buff *skb, struct timespec64 *ts, } static __u32 __packet_set_timestamp(struct packet_sock *po, void *frame, - struct sk_buff *skb) + const struct sk_buff *skb) { union tpacket_uhdr h; struct timespec64 ts; -- 2.36.1