Message ID | 20240205072013.427639-6-chentao@kylinos.cn |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-52130-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp719921dyb; Sun, 4 Feb 2024 23:32:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IHZKMiuB6oHjzOg+o7NjYwpdl+JyFVh8wR8HP1vBUCC2IE2jHIIFvXIJzNo1/1aFwTNuyVL X-Received: by 2002:a17:903:2114:b0:1d8:f249:43e8 with SMTP id o20-20020a170903211400b001d8f24943e8mr9974580ple.18.1707118334745; Sun, 04 Feb 2024 23:32:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707118334; cv=pass; d=google.com; s=arc-20160816; b=CB7rk4rIsrgrjsjxhwAvCVXBXUGBHxbtH3qAunOXne9PRmkZDHIYlQJvcqqfSPnshZ aIPTInFl2/CxcDcRfJkKIHq89eUWyLhJUzsoc/mxgBj4OQIL9vTbQ8Da+9t75YWNC7Q7 Dpk3leV2Bi9gyW16mYmh651HRMrvAtOUpJHk8q1De134p0V0W0TRUAy6ODqvaTI/X8/U JNa0g1tAKtngbF0Q+9BQO4s7A7D7Y1n3gZHMdeyUku5xJrvLtA8Q2hRVSV//RWhC+Mxh XcoagYBkM8qctc6VM8L1typsNARAXZLUOtvUz0rmb8HcW9ELnHguww5U0oSL740JI8tV jgMA== 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; bh=xnlFG+nfhFlFijs9gGKkG6m3l0HnLeicdLGqBC+a4dU=; fh=0yHayXljtOYeHNI6z58AMmy07XQRQ2T+iD4ckJv75xE=; b=V+vdrP4tEnC0EkTSK8DUuFG/jH38D5/TvR1XvG/kP9H6P0zBd2qq4H0OmG0sVvQLC6 gVPxlhFfluWpruqmaMDBQemVMD6YMVnRQkcTvEA0OeWq2tCHU5nE7aBgi47jQiNFlNg1 qK8sTXMb7Mhw6LDWYbnGgtdZeoLtbbcz9thAnsUfI3HfIhct9t+06zFn9mHz0jf/LvRp QOm5COCY+2JsZC0BfZJnuy5OLcpnsH25U+ZJgq9JRyxKaUPqA5NEeDMV1nP/nzTx6SE2 XXlwbRwidf/LK2o7p1nKB++cLQhqzPlRtvtT7Psh6Ek8ytW5ALTzIn4Vzp4wZfRAd0F1 tPCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-52130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52130-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCX+AwJkX4cVaUT9phFRZJluZCwTGjmQL6vEc4Bl3S4AtxlHMTy1GK5+9b0SPJJyxGoaDitM9n4ZBNRvVhBCaMyqFybl1A== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id n10-20020a170902e54a00b001d9a51954b1si766004plf.527.2024.02.04.23.32.14 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 23:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-52130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kylinos.cn); spf=pass (google.com: domain of linux-kernel+bounces-52130-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-52130-ouuuleilei=gmail.com@vger.kernel.org" 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 660D7B24859 for <ouuuleilei@gmail.com>; Mon, 5 Feb 2024 07:23:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 221AC1642C; Mon, 5 Feb 2024 07:21:01 +0000 (UTC) Received: from mailgw.kylinos.cn (mailgw.kylinos.cn [124.126.103.232]) (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 84E1614008; Mon, 5 Feb 2024 07:20:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=124.126.103.232 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707117659; cv=none; b=p2QfR7buEhT5sfmCzfQWeVg4passK9zsJVQPkI+GwkT/I23m8Y0vMrwkKOrZsjPF3U3y48TrxgtUhgifuoV0NeR5cuX9LmAWvhzxb5ZCDOFs5N2hrRVBqsQTalVnNKsqOvPXxsr530rGfjSHrlo9GqKQ5Zb4AwLjCkNRITLZors= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707117659; c=relaxed/simple; bh=EWhvGxiu9nKUlD223b5RUmg8URskoZ2Ajs6i2J1FTec=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LHE9Liic0D/v0t0Z5wdOOdh+WyDSxxz6YWOiqOCd3Qh72QmnfdJGyqtbKhmzMBABZeGTbcMkz8LmhkN3SfdSS5KMtqtJdiLuM7Qtn43qTJGbXsOh9IaSr2dGnngiW3WvLPZhAbuE1DiNUfViooZKrAovczKeT7luaFhJSqQQLL8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn; spf=pass smtp.mailfrom=kylinos.cn; arc=none smtp.client-ip=124.126.103.232 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kylinos.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kylinos.cn X-UUID: e1b809629f7a4cb6adc5306ec28bb32f-20240205 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.35,REQID:834f65fe-04d1-422d-887d-cfff6283464b,IP:10, URL:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:-5 X-CID-INFO: VERSION:1.1.35,REQID:834f65fe-04d1-422d-887d-cfff6283464b,IP:10,UR L:0,TC:0,Content:0,EDM:0,RT:0,SF:-15,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:5d391d7,CLOUDID:97af078f-e2c0-40b0-a8fe-7c7e47299109,B ulkID:240205152053NOLOL8W3,BulkQuantity:0,Recheck:0,SF:19|44|66|38|24|17|1 02,TC:nil,Content:0,EDM:-3,IP:-2,URL:0,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_FSD,TF_CID_SPAM_FSI,TF_CID_SPAM_SNR,TF_CID_SPAM_FAS X-UUID: e1b809629f7a4cb6adc5306ec28bb32f-20240205 Received: from mail.kylinos.cn [(39.156.73.10)] by mailgw (envelope-from <chentao@kylinos.cn>) (Generic MTA) with ESMTP id 1384232374; Mon, 05 Feb 2024 15:20:52 +0800 Received: from mail.kylinos.cn (localhost [127.0.0.1]) by mail.kylinos.cn (NSMail) with SMTP id 4B1EEE000EBC; Mon, 5 Feb 2024 15:20:52 +0800 (CST) X-ns-mid: postfix-65C08C54-11146078 Received: from kernel.. (unknown [172.20.15.254]) by mail.kylinos.cn (NSMail) with ESMTPA id 93223E000EBC; Mon, 5 Feb 2024 15:20:51 +0800 (CST) From: Kunwu Chan <chentao@kylinos.cn> To: davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, jiri@resnulli.us Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Kunwu Chan <chentao@kylinos.cn> Subject: [PATCH net-next 5/6] tcp: Simplify the allocation of slab caches Date: Mon, 5 Feb 2024 15:20:12 +0800 Message-Id: <20240205072013.427639-6-chentao@kylinos.cn> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240205072013.427639-1-chentao@kylinos.cn> References: <20240205072013.427639-1-chentao@kylinos.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790043314731631860 X-GMAIL-MSGID: 1790043314731631860 |
Series |
Use KMEM_CACHE instead of kmem_cache_create
|
|
Commit Message
Kunwu Chan
Feb. 5, 2024, 7:20 a.m. UTC
Use the new KMEM_CACHE() macro instead of direct kmem_cache_create
to simplify the creation of SLAB caches.
And change cache name from 'tcp_bind_bucket' to 'inet_bind_bucket',
'tcp_bind2_bucket' to 'inet_bind2_bucket'.
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
net/ipv4/tcp.c | 14 ++++----------
1 file changed, 4 insertions(+), 10 deletions(-)
Comments
On Mon, Feb 5, 2024 at 8:23 AM Kunwu Chan <chentao@kylinos.cn> wrote: > > Use the new KMEM_CACHE() macro instead of direct kmem_cache_create > to simplify the creation of SLAB caches. > And change cache name from 'tcp_bind_bucket' to 'inet_bind_bucket', > 'tcp_bind2_bucket' to 'inet_bind2_bucket'. > > Signed-off-by: Kunwu Chan <chentao@kylinos.cn> > --- > net/ipv4/tcp.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index a1c6de385cce..2dc3dd4323c2 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -4697,17 +4697,11 @@ void __init tcp_init(void) > thash_entries, 21, /* one slot per 2 MB*/ > 0, 64 * 1024); > tcp_hashinfo.bind_bucket_cachep = > - kmem_cache_create("tcp_bind_bucket", > - sizeof(struct inet_bind_bucket), 0, > - SLAB_HWCACHE_ALIGN | SLAB_PANIC | > - SLAB_ACCOUNT, > - NULL); > + KMEM_CACHE(inet_bind_bucket, > + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); I would prefer we do not do this. dccp is also using a kmem_cache_create() of "struct inet_bind_bucket" We want different caches for TCP and DCCP. > tcp_hashinfo.bind2_bucket_cachep = > - kmem_cache_create("tcp_bind2_bucket", > - sizeof(struct inet_bind2_bucket), 0, > - SLAB_HWCACHE_ALIGN | SLAB_PANIC | > - SLAB_ACCOUNT, > - NULL); > + KMEM_CACHE(inet_bind2_bucket, > + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); Same here. > > /* Size and allocate the main established and bind bucket > * hash tables. > -- > 2.39.2 >
Thanks for your reply. On 2024/2/5 20:29, Eric Dumazet wrote: > On Mon, Feb 5, 2024 at 8:23 AM Kunwu Chan <chentao@kylinos.cn> wrote: >> >> Use the new KMEM_CACHE() macro instead of direct kmem_cache_create >> to simplify the creation of SLAB caches. >> And change cache name from 'tcp_bind_bucket' to 'inet_bind_bucket', >> 'tcp_bind2_bucket' to 'inet_bind2_bucket'. >> >> Signed-off-by: Kunwu Chan <chentao@kylinos.cn> >> --- >> net/ipv4/tcp.c | 14 ++++---------- >> 1 file changed, 4 insertions(+), 10 deletions(-) >> >> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c >> index a1c6de385cce..2dc3dd4323c2 100644 >> --- a/net/ipv4/tcp.c >> +++ b/net/ipv4/tcp.c >> @@ -4697,17 +4697,11 @@ void __init tcp_init(void) >> thash_entries, 21, /* one slot per 2 MB*/ >> 0, 64 * 1024); >> tcp_hashinfo.bind_bucket_cachep = >> - kmem_cache_create("tcp_bind_bucket", >> - sizeof(struct inet_bind_bucket), 0, >> - SLAB_HWCACHE_ALIGN | SLAB_PANIC | >> - SLAB_ACCOUNT, >> - NULL); >> + KMEM_CACHE(inet_bind_bucket, >> + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); > > I would prefer we do not do this. > > dccp is also using a kmem_cache_create() of "struct inet_bind_bucket" When i do my work, i found this too, so i just change the cache name in tcp. > > We want different caches for TCP and DCCP. For distinguishment, I'll delete this patch in next patch series. > > >> tcp_hashinfo.bind2_bucket_cachep = >> - kmem_cache_create("tcp_bind2_bucket", >> - sizeof(struct inet_bind2_bucket), 0, >> - SLAB_HWCACHE_ALIGN | SLAB_PANIC | >> - SLAB_ACCOUNT, >> - NULL); >> + KMEM_CACHE(inet_bind2_bucket, >> + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); > > Same here. > >> >> /* Size and allocate the main established and bind bucket >> * hash tables. >> -- >> 2.39.2 >>
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index a1c6de385cce..2dc3dd4323c2 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -4697,17 +4697,11 @@ void __init tcp_init(void) thash_entries, 21, /* one slot per 2 MB*/ 0, 64 * 1024); tcp_hashinfo.bind_bucket_cachep = - kmem_cache_create("tcp_bind_bucket", - sizeof(struct inet_bind_bucket), 0, - SLAB_HWCACHE_ALIGN | SLAB_PANIC | - SLAB_ACCOUNT, - NULL); + KMEM_CACHE(inet_bind_bucket, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); tcp_hashinfo.bind2_bucket_cachep = - kmem_cache_create("tcp_bind2_bucket", - sizeof(struct inet_bind2_bucket), 0, - SLAB_HWCACHE_ALIGN | SLAB_PANIC | - SLAB_ACCOUNT, - NULL); + KMEM_CACHE(inet_bind2_bucket, + SLAB_HWCACHE_ALIGN | SLAB_PANIC | SLAB_ACCOUNT); /* Size and allocate the main established and bind bucket * hash tables.