From patchwork Thu Apr 4 15:43:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 13618014 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 53242CD1299 for ; Thu, 4 Apr 2024 15:46:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AA7026B0099; Thu, 4 Apr 2024 11:46:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A2F576B009A; Thu, 4 Apr 2024 11:46:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 882776B009B; Thu, 4 Apr 2024 11:46:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 65BE56B0099 for ; Thu, 4 Apr 2024 11:46:10 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id DE1754077F for ; Thu, 4 Apr 2024 15:46:09 +0000 (UTC) X-FDA: 81972275658.20.87FE897 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf24.hostedemail.com (Postfix) with ESMTP id A422B180023 for ; Thu, 4 Apr 2024 15:46:07 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=g802UKen; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf24.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1712245567; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=MfoG59Ii3GnXIympG3Q0TE5v8Q+0lb0NrDw41syBAIM=; b=c7hTds17d4SMzGNgrZNsxlw2ziTeXGmEE9LFZV+rsEtA1whDaNJ1ghgVsfdD4HJncCK+fV vXAXNgOeBt1rlITJn5ZhT6pKH/ggcCZ+AUC6jBkFLX7O9gtRH80a+vlN8lZW7+4wmGJZ22 Ht2fa081GsftQYfb0oEp1oPMxlOAWw8= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=g802UKen; dmarc=pass (policy=none) header.from=intel.com; spf=pass (imf24.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.12 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1712245567; a=rsa-sha256; cv=none; b=BA87JR8/yCMmR9L/nfTCnRD2v1We7pY84/oXSWhFL6HARijo0+ulI1StJTTus9GcZQsDBV ivX07bhwGsQTdpvR2XYhcDPruQbuIYWbwQzRuAmqRjEv/SwMDz3ZjBqQ1Pjo8sXipCfORW BjPipJyZ+QeGgGaM/xhJaRAVk49mylo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712245568; x=1743781568; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=h2xX5viKcqXvvZA3Hz2In9WNHWkHFwMdaq3Z6SIdJfY=; b=g802UKenTYy7sPQiAeXSjyMonJp1sPuS6Zu45xujKveOL+OmgkluvDTH F7SqHNhWQSeiQqwkUhzwHMLMfUZ33oD/LF0oYISXpLz70i8DE4DdYz/By iOf3OBn8EFqrthh/PQa6huvf3moJL2Do8Jiet0E6jJ9D3tRo5GAb1NlFY ICwr4qHfafVR5m8fwW6y4o6VT5dtQ7m5tZLI3Qp+44aQsq1Xh5Mky/Dml G+3zcrzucV9ZlHJO1grHlZxdI1IoDN5J9FLybH62Di1bJ0Hc89q263JnN o3m9S3iy2cVQCW4tk3cHpLefFA8wFBhn5yQJUOtcnKyLEKjg//De0OGR8 A==; X-CSE-ConnectionGUID: srTiYlaER7OqXo6nr724rQ== X-CSE-MsgGUID: dMMkXi3nQoqF/gDeTxR4qg== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="11312211" X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="11312211" Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Apr 2024 08:46:07 -0700 X-CSE-ConnectionGUID: wt3vYwmsS5qJdmZ4xoLx5g== X-CSE-MsgGUID: ewCrjZoNT9yCK/IOl1Mu1g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="23288081" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa005.fm.intel.com with ESMTP; 04 Apr 2024 08:46:03 -0700 From: Alexander Lobakin To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Alexander Lobakin , Alexander Duyck , Yunsheng Lin , Jesper Dangaard Brouer , Ilias Apalodimas , Christoph Lameter , Vlastimil Babka , Andrew Morton , nex.sw.ncis.osdt.itp.upstreaming@intel.com, netdev@vger.kernel.org, intel-wired-lan@lists.osuosl.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v9 5/9] page_pool: constify some read-only function arguments Date: Thu, 4 Apr 2024 17:43:58 +0200 Message-ID: <20240404154402.3581254-6-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404154402.3581254-1-aleksander.lobakin@intel.com> References: <20240404154402.3581254-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A422B180023 X-Stat-Signature: ft4e5at14me7sa6kamiomjobz6iikekm X-Rspam-User: X-HE-Tag: 1712245567-792022 X-HE-Meta: U2FsdGVkX1+nLElJIezH0RY8Jx/k7753D+6+Q2FK2I6RtKMpSn2a8Ga0tHjt24+kxl88Blj+w7SRzV+uSgOZtYBcA8/SBCWXstkqFuM+BVpd6ChU5fVwOuSGCjBxyOIQtftkP9gpy5xI2O/BKMtidJEQUZgQqDfvxrSRqKJlhb8POxCU+938LQg4orhmJ4+ODF+bqkXvVKgIvqNlFmzvlPlzelfjxA/yWo2wvt/L7V3Wqlvy7jU/NrPg5kPc6oEY/GjQ5P88gXJ0/NcyOO3LyqMlEo6EvdNeEoXNvosuVb2BRR7kAZ8WIiDvm9LV12OgYmm9pi6FVNr3Lsqh7VMjFDhZDIFY5oq9tUzK02H/QSdfFR0zCDKSBigJ9m/vAIcOWgwcOAX1YUZA9kUNrI29LQBk7f+HNjgjl9dQ+J3GJM3GoCBloDEfe8WFQbNwRBU2Tv5i6DOLj5dCBzJgqKl85NtggUYwjTdF1Gs513pMrnG73Hd5K/P1DAFJq9PDF5UXdhlJUrmnhp4Z/6IsggL2YTtANPBRb6jFbogW7vSm5UH04kno+pWq+1jPku7xd8VU4oex2oSJRfwFcwZaALdPtnUnEkd8yK8x+P53x/vLCT8m8dyQ4Yt43PhjSnu5NF9s6E/Pn2BbV4AslPSDnpBhVqnS+B1J951dmB/GKyQFOxWn7PpLgB30ozw7vtOz0bCS/AfCrfGMAeFY1IVtDGX5vSYTih9kcDaIkNQBANi0XkFd6Eb14THvDtdcPsR5PA1bGXyl8nic3ZlkWfoegCZUFfHSCANR++o4M9kOfrbnIvYntjhE9vy823AfJPIn2xyK8KuSt7bZgPd0t5bLQU979NTcbebucoPU30s+lHXp7bPcJKigW+U+5eEdeZHo5Cfu79S9qLnDbyOavKCeopJGcT6FMKCv5QNYSDaZd1295gFwhv4dEsXvj+G0+TltCZtr5EXB96m0Viv11oYZDS8 FY0WBOMy HQG46LhjYy+n87WAPMN6+yeOvJqlK2pIKE9riRhzSWfrUu2zeb6/aZQBw11HfCjWa7tECfQdBRtYssbO1Nj+lXAzwJnxgEZR2lpDLl5Gpt8Gqyy/tR9h1acuH4knFHYcWIgBrdstWexvhEZP6KNHzm1glqpP8QjsFnSZGun/v8p5OfEqSz8hxHTTomD+BHRHExkHFrYt3JnXImZMXIYvENr1jZn0nLAipsswtWHMm4iMyOpSpoQ85tUKrQ5VFGC+f8RbMIPc4qkd7l+g= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: There are several functions taking pointers to data they don't modify. This includes statistics fetching, page and page_pool parameters, etc. Constify the pointers, so that call sites will be able to pass const pointers as well. No functional changes, no visible changes in functions sizes. Reviewed-by: Ilias Apalodimas Signed-off-by: Alexander Lobakin --- include/net/page_pool/types.h | 4 ++-- include/net/page_pool/helpers.h | 10 +++++----- net/core/page_pool.c | 10 +++++----- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/include/net/page_pool/types.h b/include/net/page_pool/types.h index 5e43a08d3231..a6ebed002216 100644 --- a/include/net/page_pool/types.h +++ b/include/net/page_pool/types.h @@ -213,7 +213,7 @@ struct xdp_mem_info; #ifdef CONFIG_PAGE_POOL void page_pool_destroy(struct page_pool *pool); void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *), - struct xdp_mem_info *mem); + const struct xdp_mem_info *mem); void page_pool_put_page_bulk(struct page_pool *pool, void **data, int count); #else @@ -223,7 +223,7 @@ static inline void page_pool_destroy(struct page_pool *pool) static inline void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *), - struct xdp_mem_info *mem) + const struct xdp_mem_info *mem) { } diff --git a/include/net/page_pool/helpers.h b/include/net/page_pool/helpers.h index 1d397c1a0043..c7bb06750e85 100644 --- a/include/net/page_pool/helpers.h +++ b/include/net/page_pool/helpers.h @@ -58,7 +58,7 @@ /* Deprecated driver-facing API, use netlink instead */ int page_pool_ethtool_stats_get_count(void); u8 *page_pool_ethtool_stats_get_strings(u8 *data); -u64 *page_pool_ethtool_stats_get(u64 *data, void *stats); +u64 *page_pool_ethtool_stats_get(u64 *data, const void *stats); bool page_pool_get_stats(const struct page_pool *pool, struct page_pool_stats *stats); @@ -73,7 +73,7 @@ static inline u8 *page_pool_ethtool_stats_get_strings(u8 *data) return data; } -static inline u64 *page_pool_ethtool_stats_get(u64 *data, void *stats) +static inline u64 *page_pool_ethtool_stats_get(u64 *data, const void *stats) { return data; } @@ -204,8 +204,8 @@ static inline void *page_pool_dev_alloc_va(struct page_pool *pool, * Get the stored dma direction. A driver might decide to store this locally * and avoid the extra cache line from page_pool to determine the direction. */ -static -inline enum dma_data_direction page_pool_get_dma_dir(struct page_pool *pool) +static inline enum dma_data_direction +page_pool_get_dma_dir(const struct page_pool *pool) { return pool->p.dma_dir; } @@ -370,7 +370,7 @@ static inline void page_pool_free_va(struct page_pool *pool, void *va, * Fetch the DMA address of the page. The page pool to which the page belongs * must had been created with PP_FLAG_DMA_MAP. */ -static inline dma_addr_t page_pool_get_dma_addr(struct page *page) +static inline dma_addr_t page_pool_get_dma_addr(const struct page *page) { dma_addr_t ret = page->dma_addr; diff --git a/net/core/page_pool.c b/net/core/page_pool.c index 4c175091fc0a..273c24429bce 100644 --- a/net/core/page_pool.c +++ b/net/core/page_pool.c @@ -123,9 +123,9 @@ int page_pool_ethtool_stats_get_count(void) } EXPORT_SYMBOL(page_pool_ethtool_stats_get_count); -u64 *page_pool_ethtool_stats_get(u64 *data, void *stats) +u64 *page_pool_ethtool_stats_get(u64 *data, const void *stats) { - struct page_pool_stats *pool_stats = stats; + const struct page_pool_stats *pool_stats = stats; *data++ = pool_stats->alloc_stats.fast; *data++ = pool_stats->alloc_stats.slow; @@ -383,8 +383,8 @@ static struct page *__page_pool_get_cached(struct page_pool *pool) return page; } -static void page_pool_dma_sync_for_device(struct page_pool *pool, - struct page *page, +static void page_pool_dma_sync_for_device(const struct page_pool *pool, + const struct page *page, unsigned int dma_sync_size) { dma_addr_t dma_addr = page_pool_get_dma_addr(page); @@ -987,7 +987,7 @@ static void page_pool_release_retry(struct work_struct *wq) } void page_pool_use_xdp_mem(struct page_pool *pool, void (*disconnect)(void *), - struct xdp_mem_info *mem) + const struct xdp_mem_info *mem) { refcount_inc(&pool->user_cnt); pool->disconnect = disconnect;