Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp328218pxb; Mon, 13 Sep 2021 20:51:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrFuS8S0fChqLTNqpkb60NRjZAlCVrpvST3eIzgUGLrpyB63I17GX0+Zh2K+RGzDx74YVG X-Received: by 2002:a02:5d45:: with SMTP id w66mr12637180jaa.82.1631591512221; Mon, 13 Sep 2021 20:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631591512; cv=none; d=google.com; s=arc-20160816; b=PRBebcplR7WRHnO3qfFGQJxl+ENDRu+QdinBL0Vx+Y5jVPYLFqfydq091CBR889Sxs 4jAsNZER+5qpAn/sEFelD+Qa0310WK3KA6EYYmruBuK4HYesjA1Nt4Ji4DQgTMxjn4St qyt/DYZB0Qj8Q3iou4vBIvuzLQuikNmd5A+nGuKeBtj4CLibCAISV0430yJg2jmuuVhD 2lk4IwrRF/rJU1IfD0kQ728b6cPaQ0sx7ItJLgeC+yCp4/9yAZQVKHUx2MZwiE+GwLWS ITiWkvs1g/zOT7U4VKFjkTfK6tO96g2ZJTiDpmfx+355i3Lj9Akf9SovI8wQTJIwe28H fCbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=d3Ti+xU/m2mhoHM45+Aq1RhmFTGFJaIipaoBsexQmRI=; b=u1B5J7U9mJnrSWMGOnq5XO2RIq4A9Lk7BkXF9Bfp/3ATU5u4t87TQy7S6UjVDx0Rww spdgrtJJqi6zrTuLQwDZHfWbHAJIjYztEX4AlFIupzc1qT7vCcy32iXqqs97HzEYlLMK VGyZp4gveHRLg3dQ4d4tHbvef4S0SpAgXzJbHG9vW6TQftzsaUZN+0//dD0bYPOfen9o M3bLWETHkT0kNZkOErrGjn7t/uXCySkcZpQs/ag+eEBq92Bxhpv+LNCrDdomGcnMeKLp pIb7OuY2n0MJjCNwLvbiHCzm+0EMjQITgh/oRcG/2MbBm5kaVE7rZ31gtGabUCKaF5Oi Gsig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=aoQ7gIpY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b14si2732622iln.116.2021.09.13.20.51.40; Mon, 13 Sep 2021 20:51:52 -0700 (PDT) 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; dkim=pass header.i=@linux.dev header.s=key1 header.b=aoQ7gIpY; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239203AbhINDvV (ORCPT + 99 others); Mon, 13 Sep 2021 23:51:21 -0400 Received: from out0.migadu.com ([94.23.1.103]:64629 "EHLO out0.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238424AbhINDvT (ORCPT ); Mon, 13 Sep 2021 23:51:19 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1631591401; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=d3Ti+xU/m2mhoHM45+Aq1RhmFTGFJaIipaoBsexQmRI=; b=aoQ7gIpYbZWUFbq+zxhOTFRKPhFnjJ9qoeC+psB6ErTHfuKQZUOHSnrRU3+qHh0nRoxiFG IyGbbAjbPYeIXZF923OwZ44zyRxtje0Yu9PHQjOhlMedL3ygnWvJNFEBW+Agex1f5iZxrz ge28Q4NOI17iPOypwDl4CQw5bTLdws8= From: Yajun Deng To: davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yajun Deng , kernel test robot Subject: [PATCH net-next v2] skbuff: inline page_frag_alloc_align() Date: Tue, 14 Sep 2021 11:49:35 +0800 Message-Id: <20210914034935.19137-1-yajun.deng@linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The __alloc_frag_align() is short, and only called by two functions, so inline page_frag_alloc_align() for reduce the overhead of calls. Reported-by: kernel test robot Signed-off-by: Yajun Deng --- net/core/skbuff.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 2170bea2c7de..7c2ab27fcbf9 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -134,34 +134,31 @@ struct napi_alloc_cache { static DEFINE_PER_CPU(struct page_frag_cache, netdev_alloc_cache); static DEFINE_PER_CPU(struct napi_alloc_cache, napi_alloc_cache); -static void *__alloc_frag_align(unsigned int fragsz, gfp_t gfp_mask, - unsigned int align_mask) +void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) { struct napi_alloc_cache *nc = this_cpu_ptr(&napi_alloc_cache); - return page_frag_alloc_align(&nc->page, fragsz, gfp_mask, align_mask); -} - -void *__napi_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) -{ fragsz = SKB_DATA_ALIGN(fragsz); - return __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask); + return page_frag_alloc_align(&nc->page, fragsz, GFP_ATOMIC, align_mask); } EXPORT_SYMBOL(__napi_alloc_frag_align); void *__netdev_alloc_frag_align(unsigned int fragsz, unsigned int align_mask) { - struct page_frag_cache *nc; void *data; fragsz = SKB_DATA_ALIGN(fragsz); if (in_hardirq() || irqs_disabled()) { - nc = this_cpu_ptr(&netdev_alloc_cache); + struct page_frag_cache *nc = this_cpu_ptr(&netdev_alloc_cache); + data = page_frag_alloc_align(nc, fragsz, GFP_ATOMIC, align_mask); } else { + struct napi_alloc_cache *nc; + local_bh_disable(); - data = __alloc_frag_align(fragsz, GFP_ATOMIC, align_mask); + nc = this_cpu_ptr(&napi_alloc_cache); + data = page_frag_alloc_align(&nc->page, fragsz, GFP_ATOMIC, align_mask); local_bh_enable(); } return data; -- 2.32.0