From patchwork Tue May 28 12:55:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunsheng Lin X-Patchwork-Id: 13676654 X-Patchwork-Delegate: kuba@kernel.org Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (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 9C08016F8F8; Tue, 28 May 2024 12:59:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716901154; cv=none; b=PTLwyiBHNtxPmYTxWokuEpFFPn1g2beO7XC+EKc9ABvu+IPOvYIzLQb6w2mJ61if16HcCvEVZdIAT1eA7fN5mXcHA5qZDiiuqFZL0Fe7gk9gpdZE8bE73qteDvPjvv2ZMIsxJVXdI3ftclJE01KRn/HEnSgwrluzpxPvGNwB++k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716901154; c=relaxed/simple; bh=xunCPGVw5OVU13KIIPqigKHt/+PN8eWPlBFvP1aRIr4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ulUwjfpq8Wx7LLcVTicmbFszY2Sku2EsyZ3BfZ5kB+jKvTQ75QhSvOZLtT/vC/GdfbxEvY3T5xjJmCedAsXiihGhylo4yW75RwF7CmFkPYOdr/Ea8AN2PS6KPToUOteiMWH3T67BuoLmHgrSGNSiAUJywFhjVbybHSchyz+2MIA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4VpXYQ3FqyzxQ0N; Tue, 28 May 2024 20:55:22 +0800 (CST) Received: from dggpemm500005.china.huawei.com (unknown [7.185.36.74]) by mail.maildlp.com (Postfix) with ESMTPS id 91A85180085; Tue, 28 May 2024 20:59:10 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by dggpemm500005.china.huawei.com (7.185.36.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Tue, 28 May 2024 20:59:10 +0800 From: Yunsheng Lin To: , , CC: , , Yunsheng Lin , Alexander Duyck , Eric Dumazet Subject: [PATCH net-next v5 09/13] net: introduce the skb_copy_to_va_nocache() helper Date: Tue, 28 May 2024 20:55:59 +0800 Message-ID: <20240528125604.63048-10-linyunsheng@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20240528125604.63048-1-linyunsheng@huawei.com> References: <20240528125604.63048-1-linyunsheng@huawei.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggpemm500005.china.huawei.com (7.185.36.74) X-Patchwork-Delegate: kuba@kernel.org introduce the skb_copy_to_va_nocache() helper to avoid calling virt_to_page() and skb_copy_to_page_nocache(). CC: Alexander Duyck Signed-off-by: Yunsheng Lin --- include/net/sock.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/include/net/sock.h b/include/net/sock.h index 5f4d0629348f..7541f8dd1746 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2203,6 +2203,21 @@ static inline int skb_copy_to_page_nocache(struct sock *sk, struct iov_iter *fro return 0; } +static inline int skb_copy_to_va_nocache(struct sock *sk, struct iov_iter *from, + struct sk_buff *skb, char *va, int copy) +{ + int err; + + err = skb_do_copy_data_nocache(sk, skb, from, va, copy, skb->len); + if (err) + return err; + + skb_len_add(skb, copy); + sk_wmem_queued_add(sk, copy); + sk_mem_charge(sk, copy); + return 0; +} + /** * sk_wmem_alloc_get - returns write allocations * @sk: socket