Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp909338imu; Wed, 28 Nov 2018 01:18:29 -0800 (PST) X-Google-Smtp-Source: AFSGD/U44n4IkMrA5qTr6RUmlnAo08Fdy7GCdzcSKsyXO/t8QYa7shittU/jRVeszk9R/U17enwQ X-Received: by 2002:a63:585c:: with SMTP id i28mr32673839pgm.178.1543396709421; Wed, 28 Nov 2018 01:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543396709; cv=none; d=google.com; s=arc-20160816; b=mXL2aDjaXE/H1gL0f1+2Sh+JEY4qdE81y7y6Eec70nerl53mxfgd+KWfxqRwoq+17e DZ+g4NmV0zGZf0fyH/VlXPrZD/580Jal9Pmdxp7z5GtQdiZtIZOYKaQfRrV1Mv/80L8b AkIK7Eq2xUXyjpZs3moXEEho1zOW7tzHOr7IKvX03uPILfTBgIlgdxyzTa+VKg6PDJJF u0CuASB8wyQaNvSJtP5YccD+KYsfGlVAY/imq1otXiHBK7S2ivG5ZV/uBuE7LFbwh5R+ JfG1DWaQBwGrDJfSyrjF3zDgzq4SjI+uR+d7PKM26fK6LgV6QMmFtbaTOpwSrnkEerr0 jbwA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=tiUviWF/AJ6MRUKSCfc3sKa6V5Vx2yPnOZuGObrFXCE=; b=yjHwSlnc0p7Id5c4xIF5fzwPpGYS2A21ilcUC1AXMuex/39SdjSYKJ1LH7oGBO/Ujc WReehNfJjeK6TA0OGTOk4A6PN3aCTMRy/jIEG6Qm+xd+QacyMDf5UFcljUMKXpekLIg7 1VrRrkqBFJu/4hUzoJU79RYOsRMYxYueyLHnO4vc5ZAfSepEZAdsrhIJt4QGB+7W/BvO kIkNyap+QOLnutD9+RVJZgjgcuGVdtZpbNFYaFGQpQLE6iGa961gUtYO/13j0i/3z82l OhqoSaKBgJBM+sfwWw1dEOVOIomVqQLtCACm5NBT0tpXVbwZUFwCv0RSOZ7/1xHS4udx xQMw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si8479962pfq.19.2018.11.28.01.18.14; Wed, 28 Nov 2018 01:18:29 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727983AbeK1USM (ORCPT + 99 others); Wed, 28 Nov 2018 15:18:12 -0500 Received: from mga18.intel.com ([134.134.136.126]:34274 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727341AbeK1USM (ORCPT ); Wed, 28 Nov 2018 15:18:12 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Nov 2018 01:17:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,290,1539673200"; d="scan'208";a="112866993" Received: from shao2-debian.sh.intel.com (HELO localhost) ([10.239.13.6]) by orsmga002.jf.intel.com with ESMTP; 28 Nov 2018 01:17:14 -0800 Date: Wed, 28 Nov 2018 17:17:30 +0800 From: kernel test robot To: NeilBrown Cc: "J. Bruce Fields" , Jeff Layton , LKML , Jeff Layton , lkp@01.org, linux-nfs@vger.kernel.org Subject: Re: [PATCH] locks: fix performance regressions. Message-ID: <20181128091730.GD21676@shao2-debian> References: <20181127060102.GF6163@shao2-debian> <20181127174315.GA29963@parsley.fieldses.org> <87mupup0ot.fsf@notabene.neil.brown.name> <87k1kyowdf.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87k1kyowdf.fsf@notabene.neil.brown.name> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Nov 28, 2018 at 11:53:48AM +1100, NeilBrown wrote: > > The kernel test robot reported two performance regressions > caused by recent patches. > Both appear to related to the global spinlock blocked_lock_lock > being taken more often. > > This patch avoids taking that lock in the cases tested. > > Reported-by: kernel test robot > Signed-off-by: NeilBrown > --- > > Hi Jeff, > you might like to merge these back into the patches that introduced > the problem. > Or you might like me to re-send the series with these merged in, > in which case, please ask. > > And a BIG thank-you to the kernel-test-robot team!! > > Thanks, > NeilBrown > > fs/locks.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/fs/locks.c b/fs/locks.c > index f456cd3d9d50..67519a43e27a 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -444,6 +444,13 @@ static void locks_move_blocks(struct file_lock *new, struct file_lock *fl) > { > struct file_lock *f; > > + /* > + * As ctx->flc_lock is held, new requests cannot be added to > + * ->fl_blocked_requests, so we don't need a lock to check if it > + * is empty. > + */ > + if (list_empty(&fl->fl_blocked_requests)) > + return; > spin_lock(&blocked_lock_lock); > list_splice_init(&fl->fl_blocked_requests, &new->fl_blocked_requests); > list_for_each_entry(f, &fl->fl_blocked_requests, fl_blocked_member) > @@ -749,6 +756,20 @@ int locks_delete_block(struct file_lock *waiter) > { > int status = -ENOENT; > > + /* > + * If fl_blocker is NULL, it won't be set again as this thread > + * "owns" the lock and is the only one that might try to claim > + * the lock. So it is safe to test fl_blocker locklessly. > + * Also if fl_blocker is NULL, this waiter is not listed on > + * fl_blocked_requests for some lock, so no other request can > + * be added to the list of fl_blocked_requests for this > + * request. So if fl_blocker is NULL, it is safe to > + * locklessly check if fl_blocked_requests is empty. If both > + * of these checks succeed, there is no need to take the lock. > + */ > + if (waiter->fl_blocker == NULL && > + list_empty(&waiter->fl_blocked_requests)) > + return status; > spin_lock(&blocked_lock_lock); > if (waiter->fl_blocker) > status = 0; > -- > 2.14.0.rc0.dirty > FYI, the performance recovered back, we didn't find any regression between the two commits. commit: 48a7a13ff3 ("locks: use properly initialized file_lock when unlocking.") 8f64e497be ("locks: fix performance regressions.") 48a7a13ff31f0728 8f64e497be9929a2d5904c39c4 ---------------- -------------------------- %stddev change %stddev \ | \ 33.56 ± 3% 5% 35.30 boot-time.boot 10497 ± 3% 12% 11733 ± 4% proc-vmstat.nr_shmem 67392 68449 proc-vmstat.nr_zone_active_anon 67392 68449 proc-vmstat.nr_active_anon 16303 16206 proc-vmstat.nr_slab_reclaimable 30602 29921 proc-vmstat.nr_slab_unreclaimable 0 9e+03 9009 ± 80% latency_stats.avg.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_do_create.nfs3_proc_create.nfs_create.path_openat.do_filp_open.do_sys_open.do_syscall_64 0 6e+03 5837 ±139% latency_stats.avg.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_lookup.nfs_lookup.path_openat.do_filp_open.do_sys_open.do_syscall_64.entry_SYSCALL_64_after_hwframe 149 ± 17% 5e+03 5457 ±137% latency_stats.avg.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_getattr.__nfs_revalidate_inode.nfs_do_access.nfs_permission.inode_permission.link_path_walk.path_lookupat 175 ± 29% 4e+03 3807 ±136% latency_stats.avg.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_lookup.nfs_lookup.__lookup_slow.lookup_slow.walk_component.path_lookupat.filename_lookup 52868 ±110% -4e+04 17482 ± 4% latency_stats.avg.max 45055 ±141% -5e+04 0 latency_stats.avg.io_schedule.nfs_lock_and_join_requests.nfs_updatepage.nfs_write_end.generic_perform_write.nfs_file_write.__vfs_write.vfs_write.ksys_write.do_syscall_64.entry_SYSCALL_64_after_hwframe 227 ± 10% 1e+04 9907 ±136% latency_stats.max.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_getattr.__nfs_revalidate_inode.nfs_do_access.nfs_permission.inode_permission.link_path_walk.path_lookupat 0 9e+03 9367 ± 78% latency_stats.max.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_do_create.nfs3_proc_create.nfs_create.path_openat.do_filp_open.do_sys_open.do_syscall_64 0 6e+03 5837 ±139% latency_stats.max.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_lookup.nfs_lookup.path_openat.do_filp_open.do_sys_open.do_syscall_64.entry_SYSCALL_64_after_hwframe 175 ± 29% 4e+03 3807 ±136% latency_stats.max.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_lookup.nfs_lookup.__lookup_slow.lookup_slow.walk_component.path_lookupat.filename_lookup 98043 ±124% -8e+04 20999 ± 27% latency_stats.max.max 90059 ±141% -9e+04 0 latency_stats.max.io_schedule.nfs_lock_and_join_requests.nfs_updatepage.nfs_write_end.generic_perform_write.nfs_file_write.__vfs_write.vfs_write.ksys_write.do_syscall_64.entry_SYSCALL_64_after_hwframe 1251 ± 23% 5e+04 49005 ±137% latency_stats.sum.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_getattr.__nfs_revalidate_inode.nfs_do_access.nfs_permission.inode_permission.link_path_walk.path_lookupat 0 1e+04 12061 ± 70% latency_stats.sum.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_do_create.nfs3_proc_create.nfs_create.path_openat.do_filp_open.do_sys_open.do_syscall_64 0 6e+03 5837 ±139% latency_stats.sum.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_lookup.nfs_lookup.path_openat.do_filp_open.do_sys_open.do_syscall_64.entry_SYSCALL_64_after_hwframe 175 ± 29% 4e+03 3807 ±136% latency_stats.sum.rpc_wait_bit_killable.__rpc_execute.rpc_run_task.rpc_call_sync.nfs3_rpc_wrapper.nfs3_proc_lookup.nfs_lookup.__lookup_slow.lookup_slow.walk_component.path_lookupat.filename_lookup 90111 ±141% -9e+04 0 latency_stats.sum.io_schedule.nfs_lock_and_join_requests.nfs_updatepage.nfs_write_end.generic_perform_write.nfs_file_write.__vfs_write.vfs_write.ksys_write.do_syscall_64.entry_SYSCALL_64_after_hwframe Best Regards, Rong Chen