Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3092063imm; Sun, 5 Aug 2018 20:58:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpd1PiFYsTMY1XhkHzkSFRby6KFidSsIaT6t/O6JnL6hjOHmmeTLgmVX2bfpQGjyhf3AI2u9 X-Received: by 2002:a63:e516:: with SMTP id r22-v6mr12680961pgh.170.1533527913083; Sun, 05 Aug 2018 20:58:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533527913; cv=none; d=google.com; s=arc-20160816; b=ywoan+YNZRY7sH4KEtMM+VP+aP62aHmtsjGKXVDWY4NdXWw9GefGso6Z2OJcxGL1bE z9A82J2ENPRPflqn77XKeBLt+Kh+IslTiwSLJVkU/V8bUCwu0IorscdZBVUPl7DYA04G H5iz9t434c3vM5LB91ipNMTCYAoeK2mdKwO8avQZbAMxDQy880MokRsMxXnsQFMwx91Q JUL8w+jLmU7zOpaeAvPlnPoeUhZzvLgbxgWE/NXnipg0mELv1Ti2yM+kJASSeX+Qh/2z 5IX2rvOkoKOZ5Bx/XpzeaHey5BxYqjvX94LowMqbIWnZuQNyfKhiaRrvrqB5T4RLdIU6 4auw== 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:arc-authentication-results; bh=AIR8xJ6fQZo2twUMLmgBkz2Y7uzQaPhZO6PIr17xNQM=; b=Gb4/tg6XW3Xhs6Brh51HRT6FSeKn5Hgd2p2G52l+BY0JRKqPeXQOS2AiL5ytqoLMkg IISvOS4HCg+wGu+Y7eLB2ogKDgUpZrDRXilL3Bca2A6CD9MEpgp+XB1vUypAivusA61z HzkPTAxCgnJLqXguhfSBUcednQiEftBNOgKHgNYqlN54yVxQKYdMSlvfrJTUR6RzOikh mowi2IwFMKOffMoMH124TLNmLAZixTgNS9Z3pTkgLRd23BY5nmi6Nky0FvKqg7CAuMqL QKSyAR1GlavYxpqwQBrZFq2w4o+5GHZ317VX8ndo8YqeZVoX7YHHY03oMIS39ySYz8VV GRSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=md3KhLzo; 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 r23-v6si6004348pfr.252.2018.08.05.20.58.16; Sun, 05 Aug 2018 20:58:33 -0700 (PDT) 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=md3KhLzo; 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 S1727650AbeHFGEa (ORCPT + 99 others); Mon, 6 Aug 2018 02:04:30 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:41889 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726559AbeHFGEa (ORCPT ); Mon, 6 Aug 2018 02:04:30 -0400 Received: by mail-pl0-f66.google.com with SMTP id w19-v6so3399409ply.8; Sun, 05 Aug 2018 20:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=AIR8xJ6fQZo2twUMLmgBkz2Y7uzQaPhZO6PIr17xNQM=; b=md3KhLzo/f3IIUg0vKXK2c6ZIYBG7ePe4bYhi2SiPKEDDnVTQfQPk0EM/NUkJsZsxY USh09klGTYtXE/2yZ/n9HhfiCUqArkMP18LY9lHDYShvrvBxvxgh+S6G937/albQc+g5 lJcSEDvGpqvgWAqvXtkBiIVnM3r4RCbOgHuMgww5g6L19yCmjQaxpOCdG/FREssR9hYL CZU+KqPpnlpCFpYlq6Uw7DDGJmTIeuUHXk9jDzUPz4WM/BXN8f68yPEKZ3gzbY41CNN+ HQb9bWjoTCWHWWhRbH/LA6eBhRIA9tzg0GAOifA/F3gR9HdIUYHTpfpAQ5vfe8empcRg 8ybw== 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=AIR8xJ6fQZo2twUMLmgBkz2Y7uzQaPhZO6PIr17xNQM=; b=gUaRbACy4sDnLUBCTEhpxAj12UgsRPr+6aAmKEPJMsncPxtLSgj8a60oDTIIQvvpms AW018hxxxePvdplGAByIfpk+/AcxDOI9xz6PrveNgJM8E+IGkSyvpULBXT5d0dHxLtI2 7PqdnPW7ctSlWsRmuXXhpn2ah3OCVE14xD3C0Qhbqm7asLpr5A6+ZkWTFJVTc2339DRo P9VBqriLyX/lbpihqPQKhI7C1SjCWysES43XKYr3inkv98km4P9ee+pVcpWamJb9czDZ WUs+gPIdF6DTcSPuYZoX7bVgsohoueDqjjTwXmUM+iG3YLAJerNR0/0c/XTE/Q2OtUhA TmHQ== X-Gm-Message-State: AOUpUlGbXqLb78y/bzlFPzVXmDL5EsYlpPNkTdgMQfTmM7pzImiShnOg ocouf/ITyow/X5A3Wlv9hBSpVonjAbk= X-Received: by 2002:a17:902:5617:: with SMTP id h23-v6mr12254712pli.324.1533527843124; Sun, 05 Aug 2018 20:57:23 -0700 (PDT) Received: from bogon.didichuxing.com ([203.100.54.194]) by smtp.gmail.com with ESMTPSA id g15-v6sm17548360pfg.98.2018.08.05.20.57.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Aug 2018 20:57:22 -0700 (PDT) From: Yafang Shao To: davem@davemloft.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next] net: avoid unnecessary sock_flag() check when enable timestamp Date: Mon, 6 Aug 2018 11:57:02 +0800 Message-Id: <1533527822-3324-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 The sock_flag() check is alreay inside sock_enable_timestamp(), so it is unnecessary checking it in the caller. void sock_enable_timestamp(struct sock *sk, int flag) { if (!sock_flag(sk, flag)) { ... } } Signed-off-by: Yafang Shao --- net/compat.c | 6 ++---- net/core/sock.c | 8 ++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/net/compat.c b/net/compat.c index 7242cce..3b2105f 100644 --- a/net/compat.c +++ b/net/compat.c @@ -466,8 +466,7 @@ int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp) ctv = (struct compat_timeval __user *) userstamp; err = -ENOENT; - if (!sock_flag(sk, SOCK_TIMESTAMP)) - sock_enable_timestamp(sk, SOCK_TIMESTAMP); + sock_enable_timestamp(sk, SOCK_TIMESTAMP); tv = ktime_to_timeval(sk->sk_stamp); if (tv.tv_sec == -1) return err; @@ -494,8 +493,7 @@ int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *usersta ctv = (struct compat_timespec __user *) userstamp; err = -ENOENT; - if (!sock_flag(sk, SOCK_TIMESTAMP)) - sock_enable_timestamp(sk, SOCK_TIMESTAMP); + sock_enable_timestamp(sk, SOCK_TIMESTAMP); ts = ktime_to_timespec(sk->sk_stamp); if (ts.tv_sec == -1) return err; diff --git a/net/core/sock.c b/net/core/sock.c index e31233f..3730eb8 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -2900,8 +2900,8 @@ bool lock_sock_fast(struct sock *sk) int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp) { struct timeval tv; - if (!sock_flag(sk, SOCK_TIMESTAMP)) - sock_enable_timestamp(sk, SOCK_TIMESTAMP); + + sock_enable_timestamp(sk, SOCK_TIMESTAMP); tv = ktime_to_timeval(sk->sk_stamp); if (tv.tv_sec == -1) return -ENOENT; @@ -2916,8 +2916,8 @@ int sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp) int sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp) { struct timespec ts; - if (!sock_flag(sk, SOCK_TIMESTAMP)) - sock_enable_timestamp(sk, SOCK_TIMESTAMP); + + sock_enable_timestamp(sk, SOCK_TIMESTAMP); ts = ktime_to_timespec(sk->sk_stamp); if (ts.tv_sec == -1) return -ENOENT; -- 1.8.3.1