From patchwork Thu Apr 18 11:36:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 13634538 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 C323FC0650F for ; Thu, 18 Apr 2024 11:36:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5366F6B00A0; Thu, 18 Apr 2024 07:36:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4950B6B00A2; Thu, 18 Apr 2024 07:36:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2C07A6B00A3; Thu, 18 Apr 2024 07:36:56 -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 022576B00A0 for ; Thu, 18 Apr 2024 07:36:55 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B79D61411D1 for ; Thu, 18 Apr 2024 11:36:55 +0000 (UTC) X-FDA: 82022450790.17.FE8C792 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.11]) by imf25.hostedemail.com (Postfix) with ESMTP id 8FFB2A000C for ; Thu, 18 Apr 2024 11:36:53 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kyB+EtjK; spf=pass (imf25.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1713440213; 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=MlUAObFQ9/AbghI/E8vC1P8Sje6XVAtt7Ye+Zn5DJDw=; b=8O5Mo9ZGtAdhRUeLK5A4ZBFCkhLo3+pDWpfj4WGTEUBWrFTJC81v35CqmpK2eRUSYFTSR0 5Hvl/WFmlFY7+KGLOwnHN6zfWhl9ixN9g/AgM0ezLBxcdQw1iscVN606Po614qsdoRJwGl U8vueD/8u308Sr+x568tCSFJPN1/oDg= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b=kyB+EtjK; spf=pass (imf25.hostedemail.com: domain of aleksander.lobakin@intel.com designates 192.198.163.11 as permitted sender) smtp.mailfrom=aleksander.lobakin@intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1713440213; a=rsa-sha256; cv=none; b=klIIxI/pH46CdKeDMjg0H0kJsI3NexYi3dy5l9mqoydLq0Yn27s7RWxJyV9GKksV9KvYcT H81PCOJIhdiXlih7hiY2nnnutM5QIeuzzc5jvinIXl/F9Ml+I0zymi08blEIXfwNG9PoAV VzWxzkxWze2APuxdkZOdpsvDP9ZNSK4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713440213; x=1744976213; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=syWx/uUcwsTOQI6+xcaFeTqHxPcGMGtyCLv4nt7fle0=; b=kyB+EtjK77c0Gp23c7M8QeZrvwxYimlTA4QWmd3CkkUaTDgTxv9Xp7rf kEFMWqX3jYrxmZkGl4g0XiwK4YuOHcAYfRMnz+CxTc+8TQAf7BDp1o7jf rHYHt32J6y8+mQPCVgfQgFlWckZKgbVtCDqhwwca/8PFkg8LPoTIlxTad v+7e692CNjIFzBJSOx0nRgaUjQagw4fnsUvEfHZaXWf1GupLWa3714xhZ cULbYNyXa30g+fSQFBIab9muZFkgq4uDY6EAZlz4GDkg/zsBH8q7NOcTk zQ0EMxwsn2gCVeejtorT8Sc2J0lTM5y7XIl+cBBwkE0JMEAG7gJ7glob8 Q==; X-CSE-ConnectionGUID: kesV8BPsTYe/5xrA3s9alA== X-CSE-MsgGUID: azPNgoyYQRqqLSU5OyIOsg== X-IronPort-AV: E=McAfee;i="6600,9927,11047"; a="19587762" X-IronPort-AV: E=Sophos;i="6.07,212,1708416000"; d="scan'208";a="19587762" Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Apr 2024 04:36:53 -0700 X-CSE-ConnectionGUID: HXMUFYHRRgibQBfXelcTig== X-CSE-MsgGUID: vt0ToixcSya53zqx9wF8uQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,212,1708416000"; d="scan'208";a="27586111" Received: from newjersey.igk.intel.com ([10.102.20.203]) by fmviesa004.fm.intel.com with ESMTP; 18 Apr 2024 04:36:49 -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 , Przemek Kitszel , 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 v10 04/10] slab: introduce kvmalloc_array_node() and kvcalloc_node() Date: Thu, 18 Apr 2024 13:36:10 +0200 Message-ID: <20240418113616.1108566-5-aleksander.lobakin@intel.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240418113616.1108566-1-aleksander.lobakin@intel.com> References: <20240418113616.1108566-1-aleksander.lobakin@intel.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8FFB2A000C X-Stat-Signature: esuq55m5kfrky1knwkx5n6goykwt74u5 X-Rspam-User: X-Rspamd-Server: rspam07 X-HE-Tag: 1713440213-660178 X-HE-Meta: U2FsdGVkX1+L/xrpUYLU8HGeNHq/qUAxH0PW1yc7rWb/Y/XMp+IA7q2/eOtVkMoIN5I6TsRhSIREp+7Etyn6APyU0eGafzSrgNp5jnKH8MAvIJMe9wo5sntftAkk8mRVqIf+qNZiy7rvL6SHCtZSdx9CAPI13LEoxCMDw6xjo24U/sdaecuX8Wa39x9wKy02xyOgJnJkp/1e/pWk8vDTs6fOSxZSUU3FPTkrx+4wg53FB7xpfhap/HVQN/Asfjx4nLc0L3/qlIGN9q+DlbTXZTwwhAIOuPfErdbIGzSl99x/wsnuYH+RcNQa8JfUWV7R25f1dCPASj9eS9C/2Q16gAJbQR8JtuHOn0YGoh6l3UKsYVVq7cgxYWKM2KbuH4r5u00tc8cOCCLD7RU34Hm1ZZp80h61ZYoSVBy/+rGzbKNPVLBdQev+q8HeO1cZavvnRBBZ6cS2ptDQ4Lka0w3wuJL6bN75X3Fn4pE2OOfTUqd2ASJkUgwJwFr/X5Nxm97A95k7kxu8IuqOTWDpzWw/L/n/+C1e4iTqaW1EL6NUH9cEFUSMRSYri86PNSch19pPB6HV05aBsBg62ftr27w8PITt0n2zbynd4KfWk6y5nAeL7I5ybYEBXir/gsk/Q+U63Cru1URDd7z8uT8gBTLg5/7cDIgHok/rACWkzHWGfMySnPP7eWzP2EWUDaFif9a0vhzJc4tR3/WdbcC4OC3tmAHTfhn+c62rNnXQyY1JtLvPRiJZVOM5zVpTfq3Dv/RlcS+0nKwviK4B/O9ggZhl9u5LukitApYJ0QpqBHh3YdgLoCL/nznkC1OxfvwuC1mpu/g47eLih5wN6offkJVkJOVkOyYpgu3YL/yzX5FrOCpWSXMTB4+RAZGble1+a0d6ajja4aqhRGcA1xOGK62q7tDTXziSukNmkF9sOxf77e+9KXbp4X94S06p1wKQL237kRosI6G23aAs4cJO28k 8itFMW2K AdHAHeBlcnDw5EX66N/LP0ulkc5tnYhUbbAyJ+5AJzViheEfvbTh7NT7MhrXeWuF6iLYac+NWwtadQk6GzlQqiNPg0BIKEKKp9voUHpYf/neRnYhW7diHzjr5AV/GHWwjQGrxqkSRFaA9mtSeLT6a9DSG86NXc+N3dKyxcGgDVc13DE1xQ0y/lQssPr5B48tY+zkhk3i4W9aV7LGrvKx7TOC8527mPS5I3w9cbkTf7S1TwIbBJbi92xB3LA== 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. Acked-by: Vlastimil Babka Reviewed-by: Przemek Kitszel Signed-off-by: Alexander Lobakin --- 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)