From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 816F6C433F5 for ; Fri, 24 Sep 2021 02:49:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 67BC761090 for ; Fri, 24 Sep 2021 02:49:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243972AbhIXCv1 (ORCPT ); Thu, 23 Sep 2021 22:51:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234930AbhIXCv0 (ORCPT ); Thu, 23 Sep 2021 22:51:26 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0C9D0C061574; Thu, 23 Sep 2021 19:49:54 -0700 (PDT) MIME-Version: 1.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1632451792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=pPZqGRw1WwCLIpDnX3mQU1v67yD75RIgM3v4q/TSB/Q=; b=j9qTNzSjHAn1oA/KTXxgG36McukCNyD9HCcYZg/6jPnQsLDnldIpH8mQpNWIuv+2vBbpV9 2XrmBkEdTH0qMhUB4QqMIKHoZO8Xfk/VnePWOXMZDuBKioByrteKiZrumeRHUL7a7sO5yZ X68+P9Lkyg9k1ZwaPYdwwDNDAOcaD1Q= Date: Fri, 24 Sep 2021 02:49:51 +0000 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: yajun.deng@linux.dev Message-ID: <836595da2ba742cb790b8dd2a3c14ae4@linux.dev> Subject: Re: [PATCH net-next] net: socket: integrate sockfd_lookup() and sockfd_lookup_light() To: "Eric Dumazet" , davem@davemloft.net, kuba@kernel.org Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: References: <20210922063106.4272-1-yajun.deng@linux.dev> X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: yajun.deng@linux.dev Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org September 24, 2021 12:49 AM, "Eric Dumazet" wrot= e:=0A=0A> On 9/21/21 11:31 PM, Yajun Deng wrote:=0A> =0A>> As commit 6cb1= 53cab92a("[NET]: use fget_light() in net/socket.c") said,=0A>> sockfd_loo= kup_light() is lower load than sockfd_lookup(). So we can=0A>> remove soc= kfd_lookup() but keep the name. As the same time, move flags=0A>> to sock= fd_put().=0A> =0A> ???=0A> =0A>> Signed-off-by: Yajun Deng =0A>> ---=0A>> include/linux/net.h | 8 +++-=0A>> net/socket.c | 1= 01 +++++++++++++++++---------------------------=0A>> 2 files changed, 46 = insertions(+), 63 deletions(-)=0A>> =0A>> diff --git a/include/linux/net.= h b/include/linux/net.h=0A>> index ba736b457a06..63a179d4f760 100644=0A>>= --- a/include/linux/net.h=0A>> +++ b/include/linux/net.h=0A>> @@ -238,8 = +238,14 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg, int = flags);=0A>> struct file *sock_alloc_file(struct socket *sock, int flags,= const char *dname);=0A>> struct socket *sockfd_lookup(int fd, int *err);= =0A>> struct socket *sock_from_file(struct file *file);=0A>> -#define soc= kfd_put(sock) fput(sock->file)=0A>> int net_ratelimit(void);=0A>> +#defin= e sockfd_put(sock) \=0A>> +do { \=0A>> + struct fd *fd =3D (struct fd *)&= sock->file; \=0A>> + \=0A>> + if (fd->flags & FDPUT_FPUT) \=0A>> + fput(s= ock->file); \=0A>> +} while (0)=0A> =0A> Really ?=0A> =0A> I wonder how w= as this tested ?=0A> =0A> We can not store FDPUT_FPUT in the sock itself,= for obvious reasons.=0A> Each thread needs to keep this information priv= ate.=0A=0AThe sockfd_lookup() already changed in this patch. FDPUT_FPUT s= tored in fdget(), precisely in __fget_light().