Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3000884imu; Wed, 7 Nov 2018 03:21:32 -0800 (PST) X-Google-Smtp-Source: AJdET5daFMGdTfqz2hGatG6gzwM8x08EpoaHZlQPEYHSwStGBY/4p3CA9RzDGB7bPwl0/BzgEAzg X-Received: by 2002:a62:418a:: with SMTP id g10-v6mr1452519pfd.44.1541589692638; Wed, 07 Nov 2018 03:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541589692; cv=none; d=google.com; s=arc-20160816; b=HU83bZJEd6RvHwlymSUJ9OY7G0j7pfyKJSa1Q+iLDDwRd4x1bWY7k2uK02j9xA2KtW eAImDuCGyTI84iS9uvOZ4vNxDetyXMCPfyET+9lXMv8jdDHKvqLt0VBPvTKB91YoI5k9 RQEwvyLtdWJI7t/+MtCy1UMQslCgln1S0G/qvvpm0efyUVbEMoQAaUBSvNE8Cz3FIQ/d qtFJ/nAW3WfQ4biZHMVaIB2E652GlR3QXUt7B22QZaJh3g4dUoOnDrHqxvELt+lGf2fZ 50YX1tPU6ztAaRrn1jAKdObBSCpYSaeEHelKdsIJt+wnSPQKLEq/bTPrgU/zhKF8W1Bx H61A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=tHj/VoF2L1128brEyrVE0VniLlQnviPAFfJIa4x/4sc=; b=HI0Mmtrk4yRV2G50brNW6Lv4ZkHuSt8WVxxCgYuxU/8oVvkOlYItfGeapdiGSIAAOg 4LvrcfPLW3Gk37zJtZPjyZEsXVGqMJ4urh+QsOidbiYWuoZ9fZ30lX4LMwRqLYNEZ1QA /5A9LISRDy75/qS04wRA1GBNAyw9aPfY61bwMHAwKU81ZKfCIYXVvP+q6jWbwd4PYrmc Q6vu8ZP23Du25ZWGwefmCDXUDSqjMArELNwKjNlUcZgTyQkx4Ye6hqKWMctjCGnACW46 syg6m+56E8zEvqSQ/nRJRO8lLdLgq8BQs8h/x23jNJVdnnTgxQU2sDFc4FVkPawUaWTe uGWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KIOhfgv7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id h65-v6si352467pfc.62.2018.11.07.03.21.15; Wed, 07 Nov 2018 03:21:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KIOhfgv7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727579AbeKGUur (ORCPT + 99 others); Wed, 7 Nov 2018 15:50:47 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:37746 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726225AbeKGUur (ORCPT ); Wed, 7 Nov 2018 15:50:47 -0500 Received: by mail-pg1-f193.google.com with SMTP id c10-v6so7214546pgq.4; Wed, 07 Nov 2018 03:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=tHj/VoF2L1128brEyrVE0VniLlQnviPAFfJIa4x/4sc=; b=KIOhfgv77ULUBczCYaLDVUs/5IwzIxuCLkUMFaV3s9phs1DLnyGthzClxDpHgNBGlm h0EyNz5WoLptBG9hdChgTRTqysIH83wlGfyOi3mRt4cJjeinRNgLoBQ+QH2BcIPgCXBg fcf1ft38qjm8NtIq4MpK5sa0jwh9RzR4orflouePt+xWY3Nh9zLDjDu8Ymrnb6JbXBPe sDQS4XJ7eBPA8VijabQq4Kn25n6lCAJN42o58xwF81RLToP7sF/vzRkxNHhs0jzkWApn Ks9i5CQa0QUbYaDRh0nPkgqO6P8NsTjo54+j12esiMWjx22TfVLDkbrHXc/FVzUcxgwD pPCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=tHj/VoF2L1128brEyrVE0VniLlQnviPAFfJIa4x/4sc=; b=Ih3IxBmTFzgoiTHL8lgNFF5Lhi6lURRadpuooW/lZ52pZtTpyKSlqyQf2WmG8WhFJb IfDSLzhiaUFsTFes1vSKB//1c0hYk52KeLIwBeCzCcTFp+AfqgA7kCF5/i7U9tIJ5bjB 6FFRjPfw4moYBeGshnFQe0Hrz3wVcl5HFVH/A7f4U4TQlHQB71hreC5QnpIj1Ol486pF GA9EoKZdbqptUIuh+xhPgtZB5sj+15yp37WCAk+kVbKyOJpBqJh30hTyCRX/X37lADiy 38DsN0uXejXUrx+q0TFegMAo4OWxpbOJtcbBz4lSXOuC81Uk2YdlIIMySg4EEE/e/e1Q JHGQ== X-Gm-Message-State: AGRZ1gJLky9lQEBoLPsAIyHg3dMLd1/cptRIoIz0Um87FoiISCQiET8D DuR2iu9+mcSJL6VVTZ3uMsg= X-Received: by 2002:a63:f547:: with SMTP id e7mr1256879pgk.182.1541589651325; Wed, 07 Nov 2018 03:20:51 -0800 (PST) Received: from localhost.localdomain ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id m129-v6sm452622pfm.78.2018.11.07.03.20.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 03:20:50 -0800 (PST) From: Yafang Shao To: davem@davemloft.net, edumazet@google.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next] inet: minor optimization for backlog setting in listen(2) Date: Wed, 7 Nov 2018 19:20:16 +0800 Message-Id: <1541589617-1607-1-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Set the backlog earlier in inet_dccp_listen() and inet_listen(), then we can avoid the redundant setting. Signed-off-by: Yafang Shao --- net/dccp/proto.c | 2 +- net/ipv4/af_inet.c | 2 +- net/ipv4/inet_connection_sock.c | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/net/dccp/proto.c b/net/dccp/proto.c index 43733ac..658cd32b 100644 --- a/net/dccp/proto.c +++ b/net/dccp/proto.c @@ -948,6 +948,7 @@ int inet_dccp_listen(struct socket *sock, int backlog) if (!((1 << old_state) & (DCCPF_CLOSED | DCCPF_LISTEN))) goto out; + sk->sk_max_ack_backlog = backlog; /* Really, if the socket is already in listen state * we can only allow the backlog to be adjusted. */ @@ -960,7 +961,6 @@ int inet_dccp_listen(struct socket *sock, int backlog) if (err) goto out; } - sk->sk_max_ack_backlog = backlog; err = 0; out: diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 1fbe2f8..39066cd 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -208,6 +208,7 @@ int inet_listen(struct socket *sock, int backlog) if (!((1 << old_state) & (TCPF_CLOSE | TCPF_LISTEN))) goto out; + sk->sk_max_ack_backlog = backlog; /* Really, if the socket is already in listen state * we can only allow the backlog to be adjusted. */ @@ -231,7 +232,6 @@ int inet_listen(struct socket *sock, int backlog) goto out; tcp_call_bpf(sk, BPF_SOCK_OPS_TCP_LISTEN_CB, 0, NULL); } - sk->sk_max_ack_backlog = backlog; err = 0; out: diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 15e7f79..860e22a 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -874,7 +874,6 @@ int inet_csk_listen_start(struct sock *sk, int backlog) reqsk_queue_alloc(&icsk->icsk_accept_queue); - sk->sk_max_ack_backlog = backlog; sk->sk_ack_backlog = 0; inet_csk_delack_init(sk); -- 1.8.3.1