Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp680543lqd; Wed, 24 Apr 2024 13:37:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUbOfN5sXzVP62iQvF3xGV2db2F2yjF3OkLTYDtK33k4nCsNYvPR3tw2dD+DoW+Puz9XPAehouBiUk4tbtZFKSYyXPX6mvmB1CGptogPA== X-Google-Smtp-Source: AGHT+IE1tyLcddbf4fV97L9xPwdt4BOkjaIVt7OgavkZFShHoW4811+KxdvIIJzCt345QsK8wSRn X-Received: by 2002:a05:6a21:1f1d:b0:1a9:c3ac:be77 with SMTP id ry29-20020a056a211f1d00b001a9c3acbe77mr3627280pzb.1.1713991020845; Wed, 24 Apr 2024 13:37:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713991020; cv=pass; d=google.com; s=arc-20160816; b=eUMu02tWsC7ObRzlkCrmMkJ821+smI+06AhdJOM67Q3AyzduwrCs30xxk15JtDJUPL UVBQk1lwaKctI65LHxZ1IG140L0JtW58JDbnAkdrpOFNr+19dmpryRT7n+bQ0Q8ZXlyQ n0oIrMny1y1Ps8y5Vtlsoz30u8No0j27cFL/BMY+5osmg752V+Jk3yHysdVQbf3m8LNc KGu45EtMVkn6x5862AHhZ8erwkuE9YHPXq/T7nf8M1xp4iH9su2zO0zOV++gO21BZ1zb rPcQGI1bEGYb1/szAU/oXD6vQPLPGhYdOkCfjqu6IIrS4EPVPc/M/Qs8PVJBHbtP0oNM 8w3w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JgpIR9Yu1Qd0HbWwwZ9i6VWaq+JjveOUS87Eno8RNdA=; fh=hOzaiBW+i1HBvvIViZwXKArAAKTGfnZRyxmigg9r4L4=; b=RDTQDBzn7VgRRbpl9eH5cz9v4MiLa/UqPxc2vcAttFP6oabxVVKGUcoqOL8lLKT+/A Iq8p6I6zuR/HIPo91pgU+j86vp/UbLEB0mAKBWjzh/uLU/gPRz/TQ/ybSZBa7UA7rOqt u0OKLfh9RJV2IPMjVXlC9IzI2nTJD+ge6x8BlKNFfoXPWlek3Y1Bf/ycRE1X3eQDngCU 6nbL9HvcewACQjCIg/uvx34roDOKOjLgT4wMGVqtEys808BmUjcZtG3HafEY4w8R5ZXh Jbj7zHXjF9zf75mUIyuIWJNXM63/gaoq1D8j/+tV7SFuAmhPgDbxCMvBSpwTdmP6aFwD mlmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DHiicivi; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-157692-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157692-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id fj26-20020a056a003a1a00b006eb3b8c8fcasi12109423pfb.342.2024.04.24.13.37.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 13:37:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157692-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=DHiicivi; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-157692-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157692-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 75DDD286582 for ; Wed, 24 Apr 2024 20:37:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D385C156F40; Wed, 24 Apr 2024 20:36:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="DHiicivi" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 835DE156977; Wed, 24 Apr 2024 20:36:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713990985; cv=none; b=f7lt0FeY3gXYB49PprWfRp/1JgiLeLXeeis6285CNBBw0h0XMqNHtgyliQQTfvHH4KDWLFYsZ9LrugPO8clAM0S85cIo22OPVYRE7BiO2BT9pzDB01ELUMDdZi0W3fg+I7swASlhUmhqSgFtx5DFbuNdGUvb0R7V7O7/uozrWG0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713990985; c=relaxed/simple; bh=zZmH3xX28SQ2pUWgk2lAvl57x27IJI+kDimKqwXst20=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jSnuAVWeRRx2uFvZEsaeKHUIldLStMtMUiArpoSj3nMIHc3a945xaEIxT35HfLfNMdkIHzp16W7KwIMvKvu8dqLEYtAR+PcI11je6r7lvKJZxsHpPaMUE/6Vifmg23fBAH+BQOK7Qf1ouJBeQ8kpj1Cv0cwhGsaEU1alJvKMn6A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=DHiicivi; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1713990983; x=1745526983; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zZmH3xX28SQ2pUWgk2lAvl57x27IJI+kDimKqwXst20=; b=DHiicivi0tlI49FcVYr66zESWWCDUPFjCz0IKhnrBntu9y0pzwAVyHw6 ft9s1vRRVvovYlmNp9KCu/totpySstGJuHzGBZbkfIM/vA3GmfXDQXcbw ecX6aVHnajyoijywJRpCOwykOq+rBCf31pRvLxW1f5yJN5199c8ae/8lc 8BeGtKbYvCHWSbAmdAvAJIhqDiaDk9jx0/UWmbQx3/tlhd4OqixLfvKFl yeUS0ZEd0Zw8O+j+Tui0Z6LVuGkfew5a3M0mk+NIDwVP5fy1+Rzswxgt1 USv8pb6Dxr9NhrI5epZeyjCGITWPfh70jVSQG49N9mZD97tHcevEhf08q g==; X-CSE-ConnectionGUID: c5pcFuwfRC6ndKkhseP6KQ== X-CSE-MsgGUID: DtHAkiOpRCinC/QtV1oidQ== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="9511927" X-IronPort-AV: E=Sophos;i="6.07,227,1708416000"; d="scan'208";a="9511927" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 13:36:19 -0700 X-CSE-ConnectionGUID: EPADQ5bDTwGkPAR5b69dPw== X-CSE-MsgGUID: XrKnXTjwSQageb3PKaewdw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,227,1708416000"; d="scan'208";a="29314986" Received: from anguy11-upstream.jf.intel.com ([10.166.9.133]) by fmviesa003.fm.intel.com with ESMTP; 24 Apr 2024 13:36:19 -0700 From: Tony Nguyen To: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, edumazet@google.com, netdev@vger.kernel.org Cc: Alexander Lobakin , anthony.l.nguyen@intel.com, hawk@kernel.org, linux-mm@kvack.org, przemyslaw.kitszel@intel.com, alexanderduyck@fb.com, ilias.apalodimas@linaro.org, linux-kernel@vger.kernel.org, linyunsheng@huawei.com, nex.sw.ncis.osdt.itp.upstreaming@intel.com, cl@linux.com, akpm@linux-foundation.org, vbabka@suse.cz Subject: [PATCH net-next v11 04/10] slab: introduce kvmalloc_array_node() and kvcalloc_node() Date: Wed, 24 Apr 2024 13:35:51 -0700 Message-ID: <20240424203559.3420468-5-anthony.l.nguyen@intel.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240424203559.3420468-1-anthony.l.nguyen@intel.com> References: <20240424203559.3420468-1-anthony.l.nguyen@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Alexander Lobakin 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 Signed-off-by: Tony Nguyen --- 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) -- 2.41.0