Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp3290216imm; Fri, 20 Jul 2018 13:45:36 -0700 (PDT) X-Google-Smtp-Source: AAOMgpddF2xST19b9/LtQylQIW9QiTZ/2zho5RF6LVgtYz4FWRg1zhLr2W1LcYMGhK6Wpgm8zO42 X-Received: by 2002:a62:8559:: with SMTP id u86-v6mr3663348pfd.32.1532119536894; Fri, 20 Jul 2018 13:45:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532119536; cv=none; d=google.com; s=arc-20160816; b=xCMi+LB1v0cflkHqDzQDAiPbUPkk/+adlsZ2WWwr/aniYo8U0Q22ejqgtJzPSdLoHo ckXyivw/d/qIDtL1bbjoIaH4niheJyK93BBupZw/3MzTweA7jVqU7OhPVY5x1oX+vBe6 AuGGNIL6XekAfP88DqEGwtEG+iE21FwbQ/5GMgmMLIUhMExv0/FxtAEpc98V23YSyzNI HEIgRuPOQ2pamQfp05Yn2zhKLHkU5KrxauwPI2MsfokK1F9jTuy8Kmc+ZyjdY9o54aX/ j19fAx2dUwsbqTxjI+RnXU7lRUt2xwnzmbsB+5vXOgZjtQ2mkWcdBWwKUC7/xjg/m+Gl g1RA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=a3T/LWTS6PdYDHW3xxJwesteAkieRrcN0WBw5Qruc7A=; b=MvLv710nq/EBOnBSASR5ZEpcvqMc2HFataA2may5HB4pHIrJb8ZtupxcQjmejGDWnc pCigTBZPEWKMYaDaDlYKwH1yWypjreqAwtbEosP+H9neYpP1c45NVDjwZfKt4xeTv1xv KiSjZ0orVrk2i9DgH8/VSOKrG1d4KMvLTDlFuSgH/6rYIHV6XR6AlReOmQWnwVhVt63P 6QoafiHuDTmuqTaFHZDNmtK0nGI8Ae6AFcPpdzPFNR/a8V41mbcGUCgWZ4TDf2OjuDUs Ol2npwNjKijZzYitI5HbY+ypuN4X/Yv/OwT7l+iFn2N5ixKGJkgUb3ZDujir96W4VSFS B01Q== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u35-v6si2551219pgl.237.2018.07.20.13.45.22; Fri, 20 Jul 2018 13:45:36 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729117AbeGTVe2 (ORCPT + 99 others); Fri, 20 Jul 2018 17:34:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:53532 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727412AbeGTVe2 (ORCPT ); Fri, 20 Jul 2018 17:34:28 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.92]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 98DDEC83; Fri, 20 Jul 2018 20:44:31 +0000 (UTC) Date: Fri, 20 Jul 2018 13:44:29 -0700 From: Andrew Morton To: Davidlohr Bueso Cc: jbaron@akamai.com, viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org, Peter Zijlstra Subject: Re: [PATCH -next 0/2] fs/epoll: loosen irq safety when possible Message-Id: <20180720134429.1ba61018934b084bb2e17bdb@linux-foundation.org> In-Reply-To: <20180720200559.27nc7j2rrxpy5p3n@linux-r8p5> References: <20180720172956.2883-1-dave@stgolabs.net> <20180720124212.7260d76d83e2b8e5e3349ea5@linux-foundation.org> <20180720200559.27nc7j2rrxpy5p3n@linux-r8p5> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 20 Jul 2018 13:05:59 -0700 Davidlohr Bueso wrote: > On Fri, 20 Jul 2018, Andrew Morton wrote: > > >On Fri, 20 Jul 2018 10:29:54 -0700 Davidlohr Bueso wrote: > > > >> Hi, > >> > >> Both patches replace saving+restoring interrupts when taking the > >> ep->lock (now the waitqueue lock), with just disabling local irqs. > >> This shows immediate performance benefits in patch 1 for an epoll > >> workload running on Xen. > > > >I'm surprised. Is spin_lock_irqsave() significantly more expensive > >than spin_lock_irq()? Relative to all the other stuff those functions > >are doing? If so, how come? Some architectural thing makes > >local_irq_save() much more costly than local_irq_disable()? > > For example, if you compare x86 native_restore_fl() to xen_restore_fl(), > the cost of Xen is much higher. > > And at least considering ep_scan_ready_list(), the lock is taken/released > twice, to deal with the ovflist when the ep->wq.lock is not held. To the > point that it yields measurable results (see patch 1) across incremental > thread counts. Did you try measuring it on bare hardware? > > > >> The main concern we need to have with this > >> sort of changes in epoll is the ep_poll_callback() which is passed > >> to the wait queue wakeup and is done very often under irq context, > >> this patch does not touch this call. > > > >Yeah, these changes are scary. For the code as it stands now, and for > >the code as it evolves. > > Yes which is why I've been throwing lots of epoll workloads at it. I'm sure. It's the "as it evolves" that is worrisome, and has caught us in the past. > > > >I'd have more confidence if we had some warning mechanism if we run > >spin_lock_irq() when IRQs are disabled, which is probably-a-bug. But > >afaict we don't have that. Probably for good reasons - I wonder what > >they are? Well ignored ;) We could open-code it locally. Add a couple of WARN_ON_ONCE(irqs_disabled())? That might need re-benchmarking with Xen but surely just reading the thing isn't too expensive?