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=-2.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 DC9A0C33CB3 for ; Wed, 15 Jan 2020 19:03:34 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A6A7E2084D for ; Wed, 15 Jan 2020 19:03:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="M4kx82Z2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A6A7E2084D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3AEBC8E0005; Wed, 15 Jan 2020 14:03:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 35FA08E0003; Wed, 15 Jan 2020 14:03:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 275A58E0005; Wed, 15 Jan 2020 14:03:34 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0129.hostedemail.com [216.40.44.129]) by kanga.kvack.org (Postfix) with ESMTP id 11FAC8E0003 for ; Wed, 15 Jan 2020 14:03:34 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with SMTP id D0BC9181AEF07 for ; Wed, 15 Jan 2020 19:03:33 +0000 (UTC) X-FDA: 76380792306.09.whip63_1f3f7ad66825 X-HE-Tag: whip63_1f3f7ad66825 X-Filterd-Recvd-Size: 4179 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Jan 2020 19:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579115012; 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=h7ITH9zSXCUTo5cxF0HK0l2gxf6eSqZK0z1Jv9XNif0=; b=M4kx82Z2r0Rfqlu2ViXGSbHZVwzxlu1Wk1xFJaFoZdsKSvqlh9jI5nWtRzE68wSt4AxIKg I83jdSCL2d+WK1bFAgS0nJ2ksFWEklaCJ3F+44DXAKulKKNWx4+mC0PMwc6fJxlJu1/1Mv JFvwvl2J2tuMfwPHEqBYq7wBrDSP20s= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-17-zMv1kJxdM4aNUGL6hHUZXA-1; Wed, 15 Jan 2020 14:03:29 -0500 X-MC-Unique: zMv1kJxdM4aNUGL6hHUZXA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 512F1801E77; Wed, 15 Jan 2020 19:03:27 +0000 (UTC) Received: from llong.remote.csb (dhcp-17-59.bos.redhat.com [10.18.17.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7DBB71000329; Wed, 15 Jan 2020 19:03:23 +0000 (UTC) Subject: Re: RFC: hold i_rwsem until aio completes To: Jason Gunthorpe , Peter Zijlstra Cc: Christoph Hellwig , linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, Thomas Gleixner , Ingo Molnar , Will Deacon , Andrew Morton , linux-ext4@vger.kernel.org, cluster-devel@redhat.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20200114161225.309792-1-hch@lst.de> <20200114192700.GC22037@ziepe.ca> <20200115065614.GC21219@lst.de> <20200115132428.GA25201@ziepe.ca> <20200115143347.GL2827@hirez.programming.kicks-ass.net> <20200115144948.GB25201@ziepe.ca> From: Waiman Long Organization: Red Hat Message-ID: <849239ff-d2d1-4048-da58-b4347e0aa2bd@redhat.com> Date: Wed, 15 Jan 2020 14:03:22 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <20200115144948.GB25201@ziepe.ca> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 1/15/20 9:49 AM, Jason Gunthorpe wrote: > On Wed, Jan 15, 2020 at 03:33:47PM +0100, Peter Zijlstra wrote: >> On Wed, Jan 15, 2020 at 09:24:28AM -0400, Jason Gunthorpe wrote: >> >>> I was interested because you are talking about allowing the read/write side >>> of a rw sem to be held across a return to user space/etc, which is the >>> same basic problem. >> No it is not; allowing the lock to be held across userspace doesn't >> change the owner. This is a crucial difference, PI depends on there >> being a distinct owner. That said, allowing the lock to be held across >> userspace still breaks PI in that it completely wrecks the ability to >> analyze the critical section. > I'm not sure what you are contrasting? > > I was remarking that I see many places open code a rwsem using an > atomic and a completion specifically because they need to do the > things Christoph identified: > >> (1) no unlocking by another process than the one that acquired it >> (2) no return to userspace with locks held > As an example flow: obtain the read side lock, schedual a work queue, > return to user space, and unlock the read side from the work queue. We currently have down_read_non_owner() and up_read_non_owner() that perform the lock and unlock without lockdep tracking. Of course, that is a hack and their use must be carefully scrutinized to make sure that there is no deadlock or other potentially locking issues. Cheers, Longman