Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp593427pxb; Wed, 27 Jan 2021 16:08:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJyB416Zg9mFlDP3k6MyJS3Mtu7Gixp4CoDTWk+Xl1rnKYQT6qhbxZ40F9AOg9/9Ax2furqm X-Received: by 2002:a17:906:298b:: with SMTP id x11mr8941798eje.158.1611792493941; Wed, 27 Jan 2021 16:08:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792493; cv=none; d=google.com; s=arc-20160816; b=QZRBLAW3S6fsuk8Jm2WRQeKKv+1d/mowLT6maRa4aU5Ve/ICk+UeyPpVuOHBqF0xgO bV7lS56hhNP0ptEcibbOcTi5vRHI+tv1gVQ5xpXoQ5VMuh+hWveY+nzp5ibTXIxV5bHM Ia2w21+FayHDRwFXhlpaij7sK0Yr/9aB9UHIouqERm8Ny88ANSqTZ1A+Ig+qF1XazsEP WtoYVMZsXCPlXMHp7oNuDMaYUD14usIIC+9IeglbUQ7iOtgsOsDHuI2D/SfuSgir1FW+ 1FdJ3jqC3YRknxoy7koFNNcUp0A69tYCJBURgDJq13HRrxMrsJDLT3iKQoVM5SExoPoC /WRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=JoH0jFZd81PDLRjlMWxkm941juATXYHol9htuqWErwQ=; b=B2tO1icTM+KKErVOzh/grFrF0PFmx10hIaCFfmzPFVPlbTgE3aEVkawlIHVyKpQCB5 r1R24ZSLFeGtN6+5B5MPeC4pGTCqojpRfL9a49R3APcvRj6FlHyPhqF/aw+uYSatMFQ3 OCBOD953KHVnD0V/TD5z4QI0q4GfbTcm4HIcXuDNTaH5nesUp2P7BFwYSA0iqKMcCSWb UZqZOfERpH3/ZUyhlDO2IHelvEcriBJbvAO32bq6caDY80g/bQYx4gxGhSNxRYuAbEU4 16CtdtbjDLYTkETOhmJhNaFzzJuFC1Dt4zlCD5HFG5xMOR/QpY1+jjv7RA/KRDs0xRIi 5gZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.co.jp header.s=amazon201209 header.b=YKQtHwFQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.jp Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si1484853ejz.530.2021.01.27.16.07.49; Wed, 27 Jan 2021 16:08:13 -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=@amazon.co.jp header.s=amazon201209 header.b=YKQtHwFQ; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.co.jp Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233709AbhA0Qxx (ORCPT + 99 others); Wed, 27 Jan 2021 11:53:53 -0500 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:17255 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233602AbhA0Qxh (ORCPT ); Wed, 27 Jan 2021 11:53:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.co.jp; i=@amazon.co.jp; q=dns/txt; s=amazon201209; t=1611766417; x=1643302417; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=JoH0jFZd81PDLRjlMWxkm941juATXYHol9htuqWErwQ=; b=YKQtHwFQvfuejP5pJGD9jw3PhpZTmDA3wTHRL2ezh7Q11RIyz/9ugQV2 EWYff8pQZfVMMA162XVs88N2zxuMHZXlhj/L5Yj1kq5Q8XKYnaK0Xt4IO ntROyNfvoGXxheROrVSX9bt8rJkEONoKNDFHpIJvBlSMwf0XqxzMcHliJ g=; X-IronPort-AV: E=Sophos;i="5.79,380,1602547200"; d="scan'208";a="113899254" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-55156cd4.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 27 Jan 2021 16:52:56 +0000 Received: from EX13MTAUWB001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan2.pdx.amazon.com [10.236.137.194]) by email-inbound-relay-2b-55156cd4.us-west-2.amazon.com (Postfix) with ESMTPS id 7074EA1DD2; Wed, 27 Jan 2021 16:52:55 +0000 (UTC) Received: from EX13D04ANC001.ant.amazon.com (10.43.157.89) by EX13MTAUWB001.ant.amazon.com (10.43.161.249) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 27 Jan 2021 16:52:54 +0000 Received: from 38f9d3582de7.ant.amazon.com (10.43.162.94) by EX13D04ANC001.ant.amazon.com (10.43.157.89) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 27 Jan 2021 16:52:50 +0000 From: Kuniyuki Iwashima To: CC: , , , , , , , , Subject: Re: [PATCH net] net: Remove redundant calls of sk_tx_queue_clear(). Date: Thu, 28 Jan 2021 01:52:46 +0900 Message-ID: <20210127165246.53673-1-kuniyu@amazon.co.jp> X-Mailer: git-send-email 2.17.2 (Apple Git-113) In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.94] X-ClientProxiedBy: EX13D38UWB001.ant.amazon.com (10.43.161.10) To EX13D04ANC001.ant.amazon.com (10.43.157.89) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Eric Dumazet Date: Wed, 27 Jan 2021 15:54:32 +0100 > On Wed, Jan 27, 2021 at 1:50 PM Kuniyuki Iwashima wrote: > > > > The commit 41b14fb8724d ("net: Do not clear the sock TX queue in > > sk_set_socket()") removes sk_tx_queue_clear() from sk_set_socket() and adds > > it instead in sk_alloc() and sk_clone_lock() to fix an issue introduced in > > the commit e022f0b4a03f ("net: Introduce sk_tx_queue_mapping"). However, > > the original commit had already put sk_tx_queue_clear() in sk_prot_alloc(): > > the callee of sk_alloc() and sk_clone_lock(). Thus sk_tx_queue_clear() is > > called twice in each path currently. > > Are you sure ? > > I do not clearly see the sk_tx_queue_clear() call from the cloning part. > > Please elaborate. If sk is not NULL in sk_prot_alloc(), sk_tx_queue_clear() is called [1]. Also the callers of sk_prot_alloc() are only sk_alloc() and sk_clone_lock(). If they finally return not NULL pointer, sk_tx_queue_clear() is called in each function [2][3]. In the cloning part, sock_copy() is called after sk_prot_alloc(), but skc_tx_queue_mapping is defined between skc_dontcopy_begin and skc_dontcopy_end in struct sock_common [4]. So, sock_copy() does not overwrite skc_tx_queue_mapping, and thus we can initialize it in sk_prot_alloc(). [1] sk_prot_alloc https://github.com/torvalds/linux/blob/master/net/core/sock.c#L1693 [2] sk_alloc https://github.com/torvalds/linux/blob/master/net/core/sock.c#L1762 [3] sk_clone_lock https://github.com/torvalds/linux/blob/master/net/core/sock.c#L1986 [4] struct sock_common https://github.com/torvalds/linux/blob/master/include/net/sock.h#L218-L240 > In any case, this seems to be a candidate for net-next, this is not > fixing a bug, > this would be an optimization at most, and potentially adding a bug. > > So if you resend this patch, you can mention the old commit in the changelog, > but do not add a dubious Fixes: tag I see. I will remove the tag and resend this as a net-next candidate. Thank you, Kuniyuki > > > > This patch removes the redundant calls of sk_tx_queue_clear() in sk_alloc() > > and sk_clone_lock(). > > > > Fixes: 41b14fb8724d ("net: Do not clear the sock TX queue in sk_set_socket()") > > CC: Tariq Toukan > > CC: Boris Pismenny > > Signed-off-by: Kuniyuki Iwashima > > Reviewed-by: Amit Shah > > --- > > net/core/sock.c | 2 -- > > 1 file changed, 2 deletions(-) > > > > diff --git a/net/core/sock.c b/net/core/sock.c > > index bbcd4b97eddd..5c665ee14159 100644 > > --- a/net/core/sock.c > > +++ b/net/core/sock.c > > @@ -1759,7 +1759,6 @@ struct sock *sk_alloc(struct net *net, int family, gfp_t priority, > > cgroup_sk_alloc(&sk->sk_cgrp_data); > > sock_update_classid(&sk->sk_cgrp_data); > > sock_update_netprioidx(&sk->sk_cgrp_data); > > - sk_tx_queue_clear(sk); > > } > > > > return sk; > > @@ -1983,7 +1982,6 @@ struct sock *sk_clone_lock(const struct sock *sk, const gfp_t priority) > > */ > > sk_refcnt_debug_inc(newsk); > > sk_set_socket(newsk, NULL); > > - sk_tx_queue_clear(newsk); > > RCU_INIT_POINTER(newsk->sk_wq, NULL); > > > > if (newsk->sk_prot->sockets_allocated) > > -- > > 2.17.2 (Apple Git-113) > >