From patchwork Thu Jun 6 18:44:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 10980291 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B0121398 for ; Thu, 6 Jun 2019 18:45:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1BB328A5E for ; Thu, 6 Jun 2019 18:45:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E5CF828A74; Thu, 6 Jun 2019 18:45:08 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 964EA28A5E for ; Thu, 6 Jun 2019 18:45:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 66A276B0282; Thu, 6 Jun 2019 14:44:51 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 61DBF6B0284; Thu, 6 Jun 2019 14:44:51 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4BC9A6B0285; Thu, 6 Jun 2019 14:44:51 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by kanga.kvack.org (Postfix) with ESMTP id 2E16A6B0282 for ; Thu, 6 Jun 2019 14:44:51 -0400 (EDT) Received: by mail-qt1-f199.google.com with SMTP id t11so2885432qtc.9 for ; Thu, 06 Jun 2019 11:44:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=W85iZVgjurkkiB2a7Xxec+qLci2n6gFQqX8RW+I6lJo=; b=oHZjIpUIUZNp3ghWTRDJQQLd/disIkhkgMBaxe14KTtCqmTUKDVO2WHKNMS0RcCJEO YNsp3OVcyG1OjE47BThwVtoZXH2RymLQoL+XH/JqQSANYIueRX4d9u/XDwXCp1BL5evl +YJGQucO54c8sUEo/FemGR1JdWhGmOIXqqpuMXHssmwXq3NQbIrsy7J1e1c7ZoWRvlpr MyPEWXGDbhEQYUNC2x5KUg2XwbqKvSXKogVsemQfrzizYIhiTRSYaY4pgJ2uOewgPBaR vMOv2Gt3k68Wjj8mov1dIgEXXRKosetVqwliBYO2p+JDbCsN9UEvwysfg343Z3ipsgBw iuuQ== X-Gm-Message-State: APjAAAXeuHuOQ8EliKim3x7TOjBQBTk4IoggT0rdey7NDBekRQ+5frPP sZuM5nVL/D0dPPcBMzHRcnaUNG1Vm6AFvRkHzS1yEDmLhxzfJNJo/zzdoLEvqDEBCpLiJK6/Cgx H3ifzSo17Hq18kGOplQ6XvOAv5hPTHtxl87hYrPjKZ+3QA0khlxziVtIaeG1DlQzrXg== X-Received: by 2002:a37:bd45:: with SMTP id n66mr38370801qkf.81.1559846690946; Thu, 06 Jun 2019 11:44:50 -0700 (PDT) X-Received: by 2002:a37:bd45:: with SMTP id n66mr38370768qkf.81.1559846690424; Thu, 06 Jun 2019 11:44:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559846690; cv=none; d=google.com; s=arc-20160816; b=VP0wpbm+Akpj2UNnTCxayJVMvns4Nq/oe9VGkpt+Bx7BHvo9E4fhI2m5DxvWrVKzI7 GKREu8xlpqoMiNU/g47EEw8cJ/P+6RTk+DbgoCT5JkKU/uvOFrES23ydTd0y6mumEp14 FQRUsAOqrtpXquIj/uYZFNk57gvoDI0/JeyheG+HlkgwezyP3wwKRfSBeGeFRTi7e+XZ a7sa0M/aXx830FMErh/W6ArI3eaUPM7lzI6nN+NxIPiT8Mok8KXDTFmLYalyMZjsNR2L N4+9fSg6lleC/HhK1l43A56vPb6mXasgKRcyFKOhfZ8Gcvr1Xhw7YtRv6FsHdeHy/Ijw ysiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=W85iZVgjurkkiB2a7Xxec+qLci2n6gFQqX8RW+I6lJo=; b=fwV6NKmnIFpTMy/IrdVxbSzP/FWW9sWerXuvUQ2s1kIvGmFnzaYH3CQgcKWcayGt29 pH7tCU11PXHU05drxlDKbRU67vt41iH1sg15Ql6vSIWczW0+SHCHRh1zEnylTCdb53Pb gq6xtOjx5rct+w/Zm2E5Ue8/fZYeYAwpXhyNVmyyc29tDx04zM/omn6LU7OpcsAKYSqw 7r1frfZQJJF7oHK4TrdEyb0Mxt0BDkkuMzq0ehKJltGt67OX1T3FlaZOtbjHPXQ3GqEv ytV623J+etWjgAxfUJS+tn+rQXtjdIoyT9t1CqFgrtyxPV+56KtsEAZNckwrVZRU5lbh xtrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=EIOU+fw3; spf=pass (google.com: domain of jgg@ziepe.ca designates 209.85.220.41 as permitted sender) smtp.mailfrom=jgg@ziepe.ca Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id c8sor2108084qvj.32.2019.06.06.11.44.50 for (Google Transport Security); Thu, 06 Jun 2019 11:44:50 -0700 (PDT) Received-SPF: pass (google.com: domain of jgg@ziepe.ca designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=EIOU+fw3; spf=pass (google.com: domain of jgg@ziepe.ca designates 209.85.220.41 as permitted sender) smtp.mailfrom=jgg@ziepe.ca DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=W85iZVgjurkkiB2a7Xxec+qLci2n6gFQqX8RW+I6lJo=; b=EIOU+fw3tMulwBY+jl6o/Pd7uN1ahiKKDLJKphj0SFrY3mGFeHTn1W2VV4oFCcXr7j cWmZ0gDNudc595ZVgI5l/RmqYCimcWM0wl22l9mGjVDztbCe051fJtkZna0E33TmapUB sttvDBWVXq87dQ+6H75k5wM3twYt5qFdBFS/o7++FbtFqaun0Q5YuEHy1UH3O9BInXzS pIETiNwzZOWJnzWU1GfKDiH4km5IjkASxVzt5h0rLlByvN4VwKEz5TKRl7R8CRCPPHgC iZGZpOcpwV/Xe9ToHHJdY4NMDuY9EmTPikVd4pQhwsuT6b7FpmiV8btfYq7kPkezkCcc rh8A== X-Google-Smtp-Source: APXvYqwcFvSukVvOu/ecnBzPeUt++yQE3oiNuMCzOwlWEIQcAIcfXxOQH4AMIgicmlTTSzjQ5g0HvQ== X-Received: by 2002:a0c:989d:: with SMTP id f29mr21429512qvd.209.1559846690185; Thu, 06 Jun 2019 11:44:50 -0700 (PDT) Received: from ziepe.ca (hlfxns017vw-156-34-55-100.dhcp-dynamic.fibreop.ns.bellaliant.net. [156.34.55.100]) by smtp.gmail.com with ESMTPSA id p37sm1643204qtc.35.2019.06.06.11.44.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Jun 2019 11:44:46 -0700 (PDT) Received: from jgg by mlx.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hYxNV-0008Il-PR; Thu, 06 Jun 2019 15:44:45 -0300 From: Jason Gunthorpe To: Jerome Glisse , Ralph Campbell , John Hubbard , Felix.Kuehling@amd.com Cc: linux-rdma@vger.kernel.org, linux-mm@kvack.org, Andrea Arcangeli , dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, Jason Gunthorpe Subject: [PATCH v2 hmm 08/11] mm/hmm: Remove racy protection against double-unregistration Date: Thu, 6 Jun 2019 15:44:35 -0300 Message-Id: <20190606184438.31646-9-jgg@ziepe.ca> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190606184438.31646-1-jgg@ziepe.ca> References: <20190606184438.31646-1-jgg@ziepe.ca> MIME-Version: 1.0 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Jason Gunthorpe No other register/unregister kernel API attempts to provide this kind of protection as it is inherently racy, so just drop it. Callers should provide their own protection, it appears nouveau already does, but just in case drop a debugging POISON. Signed-off-by: Jason Gunthorpe Reviewed-by: Jérôme Glisse Reviewed-by: Ralph Campbell --- mm/hmm.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index c702cd72651b53..6802de7080d172 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -284,18 +284,13 @@ EXPORT_SYMBOL(hmm_mirror_register); */ void hmm_mirror_unregister(struct hmm_mirror *mirror) { - struct hmm *hmm = READ_ONCE(mirror->hmm); - - if (hmm == NULL) - return; + struct hmm *hmm = mirror->hmm; down_write(&hmm->mirrors_sem); list_del_init(&mirror->list); - /* To protect us against double unregister ... */ - mirror->hmm = NULL; up_write(&hmm->mirrors_sem); - hmm_put(hmm); + memset(&mirror->hmm, POISON_INUSE, sizeof(mirror->hmm)); } EXPORT_SYMBOL(hmm_mirror_unregister);