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=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 3F9AACA9EAF for ; Mon, 21 Oct 2019 19:47:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0272D2086D for ; Mon, 21 Oct 2019 19:47:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aT51DCB7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0272D2086D 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 A64436B0003; Mon, 21 Oct 2019 15:47:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A14CF6B0006; Mon, 21 Oct 2019 15:47:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B4DA6B0007; Mon, 21 Oct 2019 15:47:55 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 635136B0003 for ; Mon, 21 Oct 2019 15:47:55 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with SMTP id DCD4B8249980 for ; Mon, 21 Oct 2019 19:47:54 +0000 (UTC) X-FDA: 76068827268.29.horse25_27f4f0ddde013 X-HE-Tag: horse25_27f4f0ddde013 X-Filterd-Recvd-Size: 4223 Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 21 Oct 2019 19:47:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571687273; 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=61Nnku0I+13ll91wxHp2GCqWsterOpYjidrMjRQ6FOk=; b=aT51DCB7ojhmNw7TDihnuqU3O1x6WMVAvvkF5Vd0CFO+KiHmXIfxQXmgYUA/ZQ7GHxem1j ywFWU1qgM9lnWXrZDXyOq395VYfSGTsWfylf5/+2WHLM2nNwCBRuUn0Kw9Y/ZrTtFt0oAh 7y8I4L41S50NbJh3iMlbSUjaF0oUYLI= 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-184-tvVLh5QnNemqg5-Lf0njnA-1; Mon, 21 Oct 2019 15:47:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D6C07800D41; Mon, 21 Oct 2019 19:47:50 +0000 (UTC) Received: from redhat.com (unknown [10.20.6.178]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DB9105C219; Mon, 21 Oct 2019 19:47:49 +0000 (UTC) Date: Mon, 21 Oct 2019 15:47:48 -0400 From: Jerome Glisse To: Jason Gunthorpe Cc: Ralph Campbell , John Hubbard , "Felix.Kuehling@amd.com" , "linux-rdma@vger.kernel.org" , "linux-mm@kvack.org" , Andrea Arcangeli , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , Ben Skeggs , Michal Hocko Subject: Re: [PATCH hmm 02/15] mm/mmu_notifier: add an interval tree notifier Message-ID: <20191021194748.GA5644@redhat.com> References: <20191015181242.8343-1-jgg@ziepe.ca> <20191015181242.8343-3-jgg@ziepe.ca> <20191021183056.GA3177@redhat.com> <20191021185421.GG6285@mellanox.com> <20191021191157.GA5208@redhat.com> <20191021192448.GK6285@mellanox.com> MIME-Version: 1.0 In-Reply-To: <20191021192448.GK6285@mellanox.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: tvVLh5QnNemqg5-Lf0njnA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline 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 Mon, Oct 21, 2019 at 07:24:53PM +0000, Jason Gunthorpe wrote: > On Mon, Oct 21, 2019 at 03:11:57PM -0400, Jerome Glisse wrote: > > > Since that reader is not locked we need release semantics here to > > > ensure the unlocked reader sees a fully initinalized mmu_notifier_mm > > > structure when it observes the pointer. > >=20 > > I thought the mm_take_all_locks() would have had a barrier and thus > > that you could not see mmu_notifier struct partialy initialized.=20 >=20 > Not sure, usually a lock acquire doesn't have a store barrier? Yeah likely. >=20 > Even if it did, we would still need some pairing read barrier.. >=20 > > having the acquire/release as safety net does not hurt. Maybe add a > > comment about the struct initialization needing to be visible before > > pointer is set. >=20 > Is this clear? >=20 > * release semantics on the initialization of the > * mmu_notifier_mm's contents are provided for unlocked readers. > =09 * acquire can only be used while holding the > * mmgrab or mmget, and is safe because once created the > * mmu_notififer_mm is not freed until the mm is destroyed. > * Users holding the mmap_sem or one of the > =09 * mm_take_all_locks() do not need to use acquire semantics. >=20 > It also helps explain why there is no locking around the other > readers, which has puzzled me in the past at least. Perfect. J=E9r=F4me