Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp670655lqd; Wed, 24 Apr 2024 13:16:47 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVREh3ESA4zvHwQtWlBaWdTQMmjhPQqotAk8AP4Ndm3O866UoHvg0mgBIFkTN+XK2KxjuzKzJ67oYh1l1T4lFOWJaPQQtlD0e4DvxMQkg== X-Google-Smtp-Source: AGHT+IG6qY1A9qwXF4SMd1G5eh4Gvyriu19jeXnFdfsZ0Zg1R3j9WqOzFiU7GNhYMUQ8T2Gs+3eF X-Received: by 2002:a50:9552:0:b0:56d:c748:4792 with SMTP id v18-20020a509552000000b0056dc7484792mr2235285eda.41.1713989806915; Wed, 24 Apr 2024 13:16:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713989806; cv=pass; d=google.com; s=arc-20160816; b=ew4zV1Q2Mkay7mwRUeMVdmhRTx9WjGLip0GbfAxvTj3h4U1Fbj0TS8r6aZjLfS535w 3Mc4mAw2G5KJ3P3lvjYkiWmHQJEFslS7lS5T9DaKs1bmkVwCKPXUzneFQyjZgQnVKHCQ HWvoQvZZlpg0Z4z9S19n+85yuPtsnjrB43/SMybkYyDM8q09ldkQY8ysgtBEyNZg8tgs fwDRJj1ZsnzwRwSQia8Pdd2tIbBGIKRcWsO6g4EjQD8WT8V/gW4R6ylBE3NtCmLqV1q4 jUHvTRnMrdp9vybz9DV8S/XgJe7n8fMxOfhLJG4v8NS3NFWJFRGnp7I+cddF/hbgiovd YHSg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Iu/xXE7mMWILwwQhQoKMguWl3qQTf6tJcOhQHpORss8=; fh=KJ/5kMGF87vXCLb4xyOwHkTx557OsfxnPqS8ztVbWts=; b=uExC/Wfqsr3mEl7qwvhRNFUNEeAMjLfcN6PqHKG2ia7WB8Nq9jVndN8HPPzP1j7EOV HL1rEtypUFk8FPvsjZg3Xrw7vhGqTW8HiqIBlamrrkd2Q8xFVfvWPFo3NgEaggPBf4T/ 4lz5gs34oLF2q56iiRahmiLKnRURrYB7hhrPzEtx608+Qm2M/FpSFcWMZJ4Rvqm/uUXY 96mWUV+Eu1/gEAFLHFUedrTN7OmAO6XCRjyMncUuKYEADk+cmoX6oRH0BhnE5fAYplNs IlZm9iWw3Qsw/fMY5Lt8HSNU0KtZ+4MHkJNKVMGGumLw8uhaLc2W4PxW/2yct+tvknNH 4Nzw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ObXWnX48; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-nfs+bounces-2984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id r7-20020a056402234700b0057214db15a1si3422267eda.178.2024.04.24.13.16.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 13:16:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ObXWnX48; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-nfs+bounces-2984-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A2E1A1F25A57 for ; Wed, 24 Apr 2024 20:08:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6620C13C812; Wed, 24 Apr 2024 20:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ObXWnX48" X-Original-To: linux-nfs@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF83913BC19 for ; Wed, 24 Apr 2024 20:07:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713989239; cv=none; b=aTL/6ie/bKmZ39IX8prHhaQWj0ff24qHrpoGoZJ/f/mZMWU9lrvV7G48181jd7MW9oLzElg3kUi0jVeb7C9D1UWV1Irx6OfBkmTZhutPWN4vWjVvVUHhS6RbUwXKYu01AfSWbCYcbbUJMoy+yGyx0aBFZtaOY8d+oJBc4EUtrOM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713989239; c=relaxed/simple; bh=aiTeXlgqUc2I7PGr9DFxoEyWbZ6ebSklPhY44dp+nIo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xi6okG0NpTRE7YFMbugmV/78ZbHYWqJ+ZZ339ZpbLX9zdMRfsnupCtE5uKQit/MHiQcEJIGuZbO2vRexrpXVqm1qQOZK62Ch02F4VIFlnlOrIvedCsaClyklu930n5n5bxBGKpA67VXWp9hqwDSbgk9Ld7gWtw5bDJw1sVC+X1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=ObXWnX48; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713989236; 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: in-reply-to:in-reply-to:references:references; bh=Iu/xXE7mMWILwwQhQoKMguWl3qQTf6tJcOhQHpORss8=; b=ObXWnX48G4yDNWcoI4CfqQC3+6HON2c4mYtjCczr+/P+eoDSIie6Wqqgd0wbRZ76JzYRBt G6y2yQTTap1ecavfNZo7PF+AWMPd4y9my1Umf37aXoNitN4Css1lNByGelQH4peC+1xiWp v4gpmnrTrhMlOii8+0AaBLSjUwA01jw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-568-zoOJjm2cOBu8YVs6mbf_hQ-1; Wed, 24 Apr 2024 16:07:10 -0400 X-MC-Unique: zoOJjm2cOBu8YVs6mbf_hQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B508D8107BD; Wed, 24 Apr 2024 20:07:09 +0000 (UTC) Received: from [192.168.37.1] (ovpn-0-6.rdu2.redhat.com [10.22.0.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DD278492BC6; Wed, 24 Apr 2024 20:07:07 +0000 (UTC) From: Benjamin Coddington To: Chen Hanxiao Cc: Trond Myklebust , Anna Schumaker , Chuck Lever , Jeff Layton , Neil Brown , Olga Kornievskaia , Dai Ngo , Tom Talpey , linux-nfs@vger.kernel.org Subject: Re: [PATCH] SUNRPC: rpc_show_tasks: add an empty list check Date: Wed, 24 Apr 2024 16:07:06 -0400 Message-ID: <76BBD76E-9CDC-4B97-81E0-72839DF63498@redhat.com> In-Reply-To: <20240424104112.1053-1-chenhx.fnst@fujitsu.com> References: <20240424104112.1053-1-chenhx.fnst@fujitsu.com> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 On 24 Apr 2024, at 6:41, Chen Hanxiao wrote: > add an empty list check, so we can get rid of some useless > list iterate or spin locks. > > Signed-off-by: Chen Hanxiao > --- > net/sunrpc/clnt.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c > index 28f3749f6dc6..749317587bb3 100644 > --- a/net/sunrpc/clnt.c > +++ b/net/sunrpc/clnt.c > @@ -3345,8 +3345,13 @@ void rpc_show_tasks(struct net *net) > int header = 0; > struct sunrpc_net *sn = net_generic(net, sunrpc_net_id); > > + if (list_empty(&sn->all_clients)) > + return; > + > spin_lock(&sn->rpc_client_lock); > list_for_each_entry(clnt, &sn->all_clients, cl_clients) { > + if (list_empty(&clnt->cl_tasks)) > + continue; > spin_lock(&clnt->cl_lock); > list_for_each_entry(task, &clnt->cl_tasks, tk_task) { > if (!header) { > -- > 2.39.1 Why optimize this? Can you show the locks are contended? Its probably fine, but using list_empty outside of the lock has a bad smell to me. Ben