From patchwork Thu Apr 4 15:43:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 13618013 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 97049CD1284 for ; Thu, 4 Apr 2024 15:46:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id ACEC46B0095; Thu, 4 Apr 2024 11:46:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A7D926B0098; Thu, 4 Apr 2024 11:46:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 85AF76B0099; Thu, 4 Apr 2024 11:46:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 675266B0095 for ; Thu, 4 Apr 2024 11:46:06 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 33C59A0370 for ; Thu, 4 Apr 2024 15:46:06 +0000 (UTC) X-FDA: 81972275532.23.B7EC281 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by imf24.hostedemail.com (Postfix) with ESMTP id F0203180029 for ; Thu, 4 Apr 2024 15:46:03 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HyZNI5d0; 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=1712245564; 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=Jy1d0Xv2XVaArfdhoR+MsiwJ8k5Lq9Q2bv5xCRNmIAQ=; b=D1v8sSBitegXxdHkDRk87UoHLFmVhWmdgTsQbEszeXPlufZLH1ugvXxcnQczVgVc3ZrQaW EoM6Goed2OKDtTwZI4700LSnErwGcfAfvQbnk970VUAjrDU6OrlOf+AE4fqn75i+sNJ1iN aBtvHnazh1ZDpE75bt148TBIhXZ6mdQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=HyZNI5d0; 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=1712245564; a=rsa-sha256; cv=none; b=artEe/IoJBhTt5KztRthpzm2CAbaZW93cvcEvtgSiWxDOml/Og7Wyn7QCsvbe3pnzTAI4z lQEw5VXelDhlP61W24y8vJNgXUnBnccVIeB7OrEQtjr3BJdfiEr4ShtIQRQtQj+4jWN2t0 HRt6hKafO5tlFaTdi5KN12aJV04wPT8= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712245564; x=1743781564; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=0zdNtgo/Mi03+32brAD9ZsQQUigrMfXyFWjV5uvo34w=; b=HyZNI5d069LO6orr0Ksgq0Gnk3qwF2vGqbFbprMUWVYfuIlSBQsYFxfE xjaxmYIgBGshNl4odULEdBJrKq1GjhNKUNC/NrN7lVCGsumOdogry3oUB NPjuQfF3wBSq5VOtumOybsptI8gp8lTBraj4jIlUMy/xAbjk1VxUrYdRj EnyyOQ/Fq9s8xh+eSluVX6EU1QgfvyW5mXlwx89ltGeH10wBgwjtY0Ubn OFuT7RJcOQDNRlNSOoqb9CokPrzSTVNYdqmgKFLUaQMSNPpO8Cs42Sqqo EvlYtVSyYyY7X9XHaonFXJK+VrusmTuANhf20r5Al6Q09H5oR/ebJDtqW Q==; X-CSE-ConnectionGUID: d988XlHPSWCzRuEJk96v1A== X-CSE-MsgGUID: Y8/XBmdwQGmo9Ofe6BlSDQ== X-IronPort-AV: E=McAfee;i="6600,9927,11034"; a="11312190" X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="11312190" 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:04 -0700 X-CSE-ConnectionGUID: FHLVSIiOR0mFs333aBuJww== X-CSE-MsgGUID: 3qwMB2+XR9Kfr0a3faOH4w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,179,1708416000"; d="scan'208";a="23288071" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa005.fm.intel.com with ESMTP; 04 Apr 2024 08:46:00 -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 4/9] slab: introduce kvmalloc_array_node() and kvcalloc_node() Date: Thu, 4 Apr 2024 17:43:57 +0200 Message-ID: <20240404154402.3581254-5-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: F0203180029 X-Stat-Signature: do1yctjy4cbg79syter3x8bs7chqokdb X-Rspam-User: X-HE-Tag: 1712245563-141464 X-HE-Meta: U2FsdGVkX1+eBW40CIEpBTKj/zlSP+KXl7AgmlBh5t+N9wlTNuvSIAHNUmE0PuzCCL8jhE6K9aWBKrgA1idhKbKPwjcnWh9GTQkNCt1lxzl70Jj8xw4uSyZlHL6jplyuUycpnCdmt9A6dmghh/bI/eR8WPXTGrnk6ei8lutOzmilKqb6WgIOiIb5yTfUXGgzNe7w8Io+UUhGuvoUpMHPm3fpjbu/O15FvbTebF/thcC19tvRPA7hDnsx7H4AgMTujBY81l8jxbg5qe6yHHujCkZFY7WVfk2ny69fIxMs/Tms/4C9DvaS/dd3HqibNYo7v99j89bWhg5KJm13dH+hajuWOTkR5Hnc8gLQcZVfDYCm9XOMMIw4Nxx+LloPtGhW3O2y5t9/uNLLy08X4gDNV5CqphJF/EEnIT/h/BIghY3LT1vxxcFOJHGAl4qX4cg+VtN/bVf9eRLnAfef9Ikwxje/zY2AwML8NqiBQnJpbvZ77gfqNdZdi2rcZGX1WLUwtY/ezbjFrjTzFZoAHFZdYwNjFPGhxYi74fFPJxfyPeCk7gNShU/cu59Tzh78Iry1CFXq9adf9MdV/8K7Cc7NZLVSbrXyWELwIqnGU8fcJvIVgJYCCkIeq9C3gVSv0zV+zSvhxW+JePo95XCj7Q0W8WJgk6WTiH18FHvFGW3okEVWjIj4z0syk8bjOGbNGn3phEXqdt1NtuayB14kSwZMXKFEvU8fbWJk2P7nvydAQ8hGxfRYdur0yqPgBVQetNbmMvH8pjzvexiWadHYClUP283KK3p5j1EGUgmDucJlEqKlVu56PpTBI+IIfY7E+7pnczZtkaKgkE1zBVzvSS4AsArIS3dSoqFEy7aE+fyj/PRcy3A2KJfJtlxxHMw5euGPDDqxx9ux4pzBCHziqemhxfS/+Otp9N6qKh+agxtEmK61TFu2EP7iIdkpL9mjg+n8r64Wq3pUnN0xFj39jRg Bc1Rd1E6 SZrKpuqa91s4zJCWGPYO44ztKchEHabArtRAOut7F/h3i4f5TJNPcm+M7WGW5zHrNC6xDzASWQR7ktatwY7MpirO0X0za2C8hqgOC9UVq2uopYPcFOb6tmUEZcd3Q2/ZYXHPzjtD26G2pnckGZ4GlC8Vs6LwXVvFv5rTDg+yGnf0P5HgKnb31wZyKv2KZR7A5bpmx1OdSmC8MIs8= 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: Add NUMA-aware counterparts for kvmalloc_array() and kvcalloc() to be able to flexibly allocate arrays for a particular node. Rewrite kvmalloc_array() to kvmalloc_array_node(NUMA_NO_NODE) call. Signed-off-by: Alexander Lobakin Reviewed-by: Przemek Kitszel Acked-by: Vlastimil Babka --- include/linux/slab.h | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/include/linux/slab.h b/include/linux/slab.h index e53cbfa18325..d1d1fa5e7983 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -774,14 +774,27 @@ static inline __alloc_size(1) void *kvzalloc(size_t size, gfp_t flags) return kvmalloc(size, flags | __GFP_ZERO); } -static inline __alloc_size(1, 2) void *kvmalloc_array(size_t n, size_t size, gfp_t flags) +static inline __alloc_size(1, 2) void * +kvmalloc_array_node(size_t n, size_t size, gfp_t flags, int node) { size_t bytes; if (unlikely(check_mul_overflow(n, size, &bytes))) return NULL; - return kvmalloc(bytes, flags); + return kvmalloc_node(bytes, flags, node); +} + +static inline __alloc_size(1, 2) void * +kvmalloc_array(size_t n, size_t size, gfp_t flags) +{ + return kvmalloc_array_node(n, size, flags, NUMA_NO_NODE); +} + +static inline __alloc_size(1, 2) void * +kvcalloc_node(size_t n, size_t size, gfp_t flags, int node) +{ + return kvmalloc_array_node(n, size, flags | __GFP_ZERO, node); } static inline __alloc_size(1, 2) void *kvcalloc(size_t n, size_t size, gfp_t flags)