Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5819205pxb; Wed, 26 Jan 2022 23:29:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6gD3ffVdg5DYV07Vv1rOB/BuW+Aelryu/4CNk/nLaDYZG19n0Twr3j9QwtJ5xYOe6d1eV X-Received: by 2002:a17:902:6502:: with SMTP id b2mr1987748plk.43.1643268551822; Wed, 26 Jan 2022 23:29:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643268551; cv=none; d=google.com; s=arc-20160816; b=oBm1uYva136RgYTi/83UwVHS3LH8dOH6WT03zkLE0g0VfIyGTOfnspEYDULM+35sgl Jo2tFJfZ2ikmzmkV3E/s6Cklb2rqsIborJ2wTWY2J9r2WWMU28bvCPc4CnO9KuUDXvZc 7W8/jAlv4TVBxFuYmZRZNyrgOpIjNSO++r+ojAKoMfqP5B+TopsVpKqEIlIQrhigBlFe dcVWTspFUwrs7zarL7Sf8zbRtWwNCrcH2SFxM3k1fAseKtDyFkVPVSR/HTH23o+GBmKt cmiOneDWzVo6udAqAf11qlYeC2SJaw4G5HW3/W1nrVNh6t/XW564WN0W/Qwtk+hgpLwW w5UQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BZekbOX/mBkxJ3VLK+5yn7uRMRqRi36JXBTZy8Qw+hU=; b=Jvhguw7BGEocLrSE2er+SWI95Ht4zmtV4lYOZZyf+Ab83DJjc4mCPYUGkJRliw9tv9 7dvfQITTd/Rd8R0MNseBmXGRvuk+mN64u3Y0k7V7cRY7E70CgA0ab2brAImSnnJGGRSm IKGmsKTyDiLNO21PWIQuMzEr1krGzQg+Eo+26ZxBBuHMCIYQhvM+w4zsTCl9CeHEfdBT Lq0aUWk/jzFkbX/rIAV1TDVjTOBxtCR9F6ZEbB3rWxAtvt1aLnlU2NM81feiCbwJWbhJ R65MBLYr8N/LRmgOZ824eHWzLaMKQg3wdQ2G9fSxnywtH+c/PmqpnwIjNL8NkOjSuHqm CWUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aRARrOuu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bm9si1509873pgb.602.2022.01.26.23.29.00; Wed, 26 Jan 2022 23:29:11 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=aRARrOuu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233962AbiA0Agl (ORCPT + 99 others); Wed, 26 Jan 2022 19:36:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233908AbiA0Agk (ORCPT ); Wed, 26 Jan 2022 19:36:40 -0500 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DA4C06173B; Wed, 26 Jan 2022 16:36:39 -0800 (PST) Received: by mail-ed1-x532.google.com with SMTP id n10so1444550edv.2; Wed, 26 Jan 2022 16:36:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BZekbOX/mBkxJ3VLK+5yn7uRMRqRi36JXBTZy8Qw+hU=; b=aRARrOuufabe73tJxz7WsJYCFwSCAb0ziKrgi23PM7QAo7XrZCEecBr3jEc1RB4fkN BL/twvydFqXcFIhS23ShhtTuMDmKGL2oei08Ld5C/2r/uib/H3/OSVzZhBm1/u8te4L+ VTPLM6tHwfdDvNVlEWNOKK9i9J8fo+LRDXSZqqySUPoHq8PLipA4F1miP4AP6SlLUmIU GgNnXKdXXGiRAN734tNuO5tXiqcglbDZbICEsfZCFjF8yhfsxrtjvOuwJslsO+6vk3TB iUh4jwO9iLpgLVD7JtfV2vy2UgFQkx3JY9wHyeNCflJozVCFR9eHATje8JBpsCKP1Bzt DpuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BZekbOX/mBkxJ3VLK+5yn7uRMRqRi36JXBTZy8Qw+hU=; b=znz6VmydKrZShzBIvD1rZ+w/e71Uk9NJkl4obWTQPlWh0JOOfjCgwyAE9EzAaafgsW JjU2EQjY/wczYmBnIFORy/SyTh/8NOmD0fkHnAw0GcbbwAtCqM2JsplLiSXNTLgZ0Hp6 NvN7gFmcF84yoS0gF9owzQiPQBRXDC+JQwy/uyxsKB7hxX6Ba9Ae9UAj1sNUy6nSQ9TQ 1j9kcnNAkCzfs6TR9KKaaj39uHAHlUc8aMx9/psvlS9nYAUTQHSisXzfKV6kYUudgkNp F5QaJEk7WFPpw6/33Yyh0xKZ2ZkwhpBfnATImoK9RNqUJc5IPJzcPHIyf+JgPJH76vQp GH1A== X-Gm-Message-State: AOAM531QZVK+hqNT8jPXWkxdRb36AjPU2PEtDdvPb4R12PRZfj3bcQJC EXzmPXglCbWONFWOcxi84DiasnX+kQA= X-Received: by 2002:a50:e616:: with SMTP id y22mr1353944edm.277.1643243798103; Wed, 26 Jan 2022 16:36:38 -0800 (PST) Received: from 127.0.0.1localhost ([85.255.234.222]) by smtp.gmail.com with ESMTPSA id op27sm8039235ejb.103.2022.01.26.16.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jan 2022 16:36:37 -0800 (PST) From: Pavel Begunkov To: netdev@vger.kernel.org, "David S . Miller" , Jakub Kicinski Cc: Eric Dumazet , Willem de Bruijn , linux-kernel@vger.kernel.org, Paolo Abeni , Pavel Begunkov Subject: [PATCH net-next v2 01/10] ipv6: optimise dst refcounting on skb init Date: Thu, 27 Jan 2022 00:36:22 +0000 Message-Id: <647e136457fb586846933244448652547dd306f9.1643243772.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org __ip6_make_skb() gets a cork->dst ref, hands it over to skb and shortly after puts cork->dst. Save two atomics by stealing it without extra referencing, ip6_cork_release() handles NULL cork->dst. Signed-off-by: Pavel Begunkov --- net/ipv6/ip6_output.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 2995f8d89e7e..14d607ccfeea 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1807,6 +1807,15 @@ int ip6_append_data(struct sock *sk, } EXPORT_SYMBOL_GPL(ip6_append_data); +static void ip6_cork_steal_dst(struct sk_buff *skb, struct inet_cork_full *cork) +{ + struct dst_entry *dst = cork->base.dst; + + cork->base.dst = NULL; + cork->base.flags &= ~IPCORK_ALLFRAG; + skb_dst_set(skb, dst); +} + static void ip6_cork_release(struct inet_cork_full *cork, struct inet6_cork *v6_cork) { @@ -1889,7 +1898,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk, skb->tstamp = cork->base.transmit_time; - skb_dst_set(skb, dst_clone(&rt->dst)); + ip6_cork_steal_dst(skb, cork); IP6_UPD_PO_STATS(net, rt->rt6i_idev, IPSTATS_MIB_OUT, skb->len); if (proto == IPPROTO_ICMPV6) { struct inet6_dev *idev = ip6_dst_idev(skb_dst(skb)); -- 2.34.1