Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp148106pxb; Wed, 18 Nov 2020 00:17:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzHhlPoxcVk0Q9Q5M9npHMdJCjfHbbHdnG33C+xlU8ghp9dn06GfFTiC9jgPto/hTEvkXV X-Received: by 2002:a50:fb13:: with SMTP id d19mr2299079edq.133.1605687445145; Wed, 18 Nov 2020 00:17:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605687445; cv=none; d=google.com; s=arc-20160816; b=0Ey5bkiC3cyAexpo/3oKOtFm5EVPcX/2DghP1RySnsgziwZoFJJE12I+EwAdTTxJe1 y/6xhaj1axx7mWMfw3xy88LGwYpzZMM/JaKpnXJZyiT2YILcxc37JycttjIBWla9tnkI 0n1VsN/OxpMOweUTvKYLIQhrBW/SG9JMzcHH2/HSXodTKnjRpgHXbAS4JU6svSAD7MHt OOGQHrRL6cQCzmxPJl0rZdpKNAyzre9ysnBefbdY87sZHOhWFj7GOAXReTrECxWsFsX3 r3/jt9Vd6W2WJbnpzIZbpb8xQS3msgCo0m9Jso4oxcP9ifDPlpSThQn2m7rKYEeQKqZX uxEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=uIuxzQH0O/MAKXgOjO+3yMwrATUjyn2cvC9p0eQHYXg=; b=x0PmvBKH7h+TVEwVtnm8kDBVv1l1ebtp2THIHbdusPhy1/B8Dbv+79no2TmJkqS1Uf frKNdEl3nnh1eqJLrl7zAXD/0cMr2IDWn1kXfA5qaYdJXuPGCSLp3QVauXbp33VnyhL0 lRpK7AZR/+i6/FtGzVf1AHVpFeppKy6kq9IruKghM6qqnCy7MP3+EFbmaUmCz8AjdBkK qT0LqsUXQaCkthItz63MVZIMoFfPGuX+Z2Pumq/Cp5L1qJeTqKk/Iu63ze2S/0v00sUV hsUy4/5rfbUOE3jGAa8MeT1rPHSanbDLmtBJLwUax8t9iLmTghZklbU8/arf7pGH6zn1 21fQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f27si18023559ejf.749.2020.11.18.00.17.02; Wed, 18 Nov 2020 00:17:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726763AbgKRIOz (ORCPT + 99 others); Wed, 18 Nov 2020 03:14:55 -0500 Received: from szxga07-in.huawei.com ([45.249.212.35]:7930 "EHLO szxga07-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726181AbgKRIOz (ORCPT ); Wed, 18 Nov 2020 03:14:55 -0500 Received: from DGGEMS410-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4CbbFT6phLz6yM6; Wed, 18 Nov 2020 16:14:37 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS410-HUB.china.huawei.com (10.3.19.210) with Microsoft SMTP Server id 14.3.487.0; Wed, 18 Nov 2020 16:14:42 +0800 From: Tian Tao To: , , , , , , , , , , , , Subject: [PATCH] net/core: use xx_zalloc instead xx_alloc and memset Date: Wed, 18 Nov 2020 16:15:08 +0800 Message-ID: <1605687308-57318-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org use kmem_cache_zalloc instead kmem_cache_alloc and memset. Signed-off-by: Tian Tao --- net/core/skbuff.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index c9a5a3c..3449c1c 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -313,12 +313,10 @@ struct sk_buff *__build_skb(void *data, unsigned int frag_size) { struct sk_buff *skb; - skb = kmem_cache_alloc(skbuff_head_cache, GFP_ATOMIC); + skb = kmem_cache_zalloc(skbuff_head_cache, GFP_ATOMIC); if (unlikely(!skb)) return NULL; - memset(skb, 0, offsetof(struct sk_buff, tail)); - return __build_skb_around(skb, data, frag_size); } @@ -6170,12 +6168,10 @@ static void *skb_ext_get_ptr(struct skb_ext *ext, enum skb_ext_id id) */ struct skb_ext *__skb_ext_alloc(gfp_t flags) { - struct skb_ext *new = kmem_cache_alloc(skbuff_ext_cache, flags); + struct skb_ext *new = kmem_cache_zalloc(skbuff_ext_cache, flags); - if (new) { - memset(new->offset, 0, sizeof(new->offset)); + if (new) refcount_set(&new->refcnt, 1); - } return new; } -- 2.7.4