From patchwork Mon Jun 24 21:01:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 11014105 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 D26AC14E5 for ; Mon, 24 Jun 2019 21:02:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C291C288FC for ; Mon, 24 Jun 2019 21:02:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3AB328949; Mon, 24 Jun 2019 21:02:07 +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 BFE082891A for ; Mon, 24 Jun 2019 21:02:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A89526B0007; Mon, 24 Jun 2019 17:02:05 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A2E468E0003; Mon, 24 Jun 2019 17:02:05 -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 91E178E0002; Mon, 24 Jun 2019 17:02:05 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by kanga.kvack.org (Postfix) with ESMTP id 46F166B0007 for ; Mon, 24 Jun 2019 17:02:05 -0400 (EDT) Received: by mail-wr1-f72.google.com with SMTP id e6so6857271wrv.20 for ; Mon, 24 Jun 2019 14:02:05 -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=rs1sEkzygtR6lbRJ0eUbAFkZlHYnT1CPNgA7awG9NQc=; b=D4BvSBgYpS5IxpPNmX0vv1uWrHU4rNZ+drk95kMvUKqB2zsmMS48OCZbP3bFjL+MUl ywbDZ0RwoxFhiStiI0/R5mWKyEBW2ZkyWMU1NOusNM0C7LXj27pCuC1sugUyxc1LuEZy QPgYT5NO1kx3meTe6CavYnlek661EK+AIqqePCwYMeysYvGdkRk/qpzXYdbrD+Ax25Kp pTE81M3lVeXu45lO/TCgqF6z1e/vFgQkgzulNWz5OFY6OtOkUTh6FOG87tzshpmEhHlR j5CFD9C5mYP0v+yShJOhYnm+F7mrSpZ5KVpt8+MExsgZ+egDm8QLHlyFJZpbmq/SAhs3 PWSA== X-Gm-Message-State: APjAAAWC/fXJfolWipoW9TLsvdGSqeqYBSiGXT6cs4RJr8bGZQ4mmeeQ IkcXqOvklYnvZ1G9Na75VJaaYfjUaxCgTvhmRuUUqkfmzWlPQL5SgIaTcyQ4H0qZlSVMDf+shqr SxphnELMf5MhYlrXW11g0yvVHwOBjEmPqXplyzKKP41PTUvRrcuZ33FhAECcakGtdnQ== X-Received: by 2002:a5d:4302:: with SMTP id h2mr15490214wrq.137.1561410124612; Mon, 24 Jun 2019 14:02:04 -0700 (PDT) X-Received: by 2002:a5d:4302:: with SMTP id h2mr15490190wrq.137.1561410123789; Mon, 24 Jun 2019 14:02:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561410123; cv=none; d=google.com; s=arc-20160816; b=PaUMIEuU4X0FRh7dyJalFqecQrJgo8mvhM3XUtAIJV4b6MYxlOxsU1RxxYDepGtYM+ X0XDiGLzV43KUtEfzypIIzejqK4Y56nU9YYY4ofVSDgFl4FvnByOCTIGkyed/LioJV2J O0vq0/myYqHlqaQXdmxx+Y/bYHRxYfTduXHmnTLzMrtc0ba3DcnRzIIgRLvO5IA0v8GR dOZbShGQDPoosoHmeaBo3QUwupjqRBm/ecd3+FHOWpkvXsvrY+AgIoEtSw3yPmWcLcp1 Hrn1NBRfbJQAk9frfmUm43T/MGTD/BVj502CPCy+VHL1hxSMLi7sTTtat4AiufROsU3m 32VA== 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=rs1sEkzygtR6lbRJ0eUbAFkZlHYnT1CPNgA7awG9NQc=; b=TaY3kQ29TEDZmgNG6GU748XaPWzFbhERT+l132UBwtMdHUndXe4sGfvwEyInbAJwwS i4LTrjog1tyckYYrKA6d4mkXPjVUsVH6Rvro+U80nXwZLveGq9kZkaZdRqkl4worOKNb 8SSFeSZKlCMfSxBWWPKTs8WDUJkRqYr/gGYTrDtfry6kapXQyH5qgpiwZBBIuXZ0wZVD cPGQJqOjAIOv8uQUF6JyGdz6rk8TJP51ajkQt1ZUITQDygdRN1alpsBfqo2vF+cD9JVE UTWjN39IR47kAL0+T8tQMhI5Pwq3pR25mDuDd1bblDJJRrIcS1l6oCIxl0DITlHJHz1c Q+gQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=f0F8mUp3; spf=pass (google.com: domain of jgg@ziepe.ca designates 209.85.220.65 as permitted sender) smtp.mailfrom=jgg@ziepe.ca Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id n10sor7223427wrq.21.2019.06.24.14.02.03 for (Google Transport Security); Mon, 24 Jun 2019 14:02:03 -0700 (PDT) Received-SPF: pass (google.com: domain of jgg@ziepe.ca designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@ziepe.ca header.s=google header.b=f0F8mUp3; spf=pass (google.com: domain of jgg@ziepe.ca designates 209.85.220.65 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=rs1sEkzygtR6lbRJ0eUbAFkZlHYnT1CPNgA7awG9NQc=; b=f0F8mUp38+BSw/O1WjANVXVVMw8zhFZORjdRX1RtgtwdBgUWBtS4DuFgknhtRckqjJ fDPYac3PHVynkBRdhou+SH6UptVQIxVUIQifavRFZYv+BeWfES7diE3vVczt6RfpUEOL HKyKRdDLLYkWyPF33zlBvSCxa/KBn2/+Y2Sy1hmyEQzxoSkWZdP4GxRWfGqLBUquGL9C Ly8tJeOzyL9mpaDnKGNVFtycDXcnewWGVJEzIZFjBXuryCCVlKkVubMEGUB9qDKesfui S5zt2wnmoNX0dsm2two3hmXge0XbsLY2LY0GsVP/TYD0CD+hqf8x5J0pMRR0Lz+jvG54 bukQ== X-Google-Smtp-Source: APXvYqxoDaUcVHfte6JF2hIkD4U/Q2PNoEzAwuS3zYv3vRjkVzwDyM9fIRPi2AhLNMqFWzhsn/OFnQ== X-Received: by 2002:a5d:5446:: with SMTP id w6mr102260622wrv.164.1561410123399; Mon, 24 Jun 2019 14:02:03 -0700 (PDT) Received: from ziepe.ca ([66.187.232.66]) by smtp.gmail.com with ESMTPSA id h14sm11086221wrs.66.2019.06.24.14.02.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jun 2019 14:02:02 -0700 (PDT) Received: from jgg by jggl.ziepe.ca with local (Exim 4.90_1) (envelope-from ) id 1hfW6D-0001Mp-1k; Mon, 24 Jun 2019 18:02:01 -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, Ben Skeggs , Christoph Hellwig , Philip Yang , Ira Weiny , Jason Gunthorpe Subject: [PATCH v4 hmm 09/12] mm/hmm: Remove racy protection against double-unregistration Date: Mon, 24 Jun 2019 18:01:07 -0300 Message-Id: <20190624210110.5098-10-jgg@ziepe.ca> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190624210110.5098-1-jgg@ziepe.ca> References: <20190624210110.5098-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, and it appears nouveau already does. Signed-off-by: Jason Gunthorpe Reviewed-by: Jérôme Glisse Reviewed-by: John Hubbard Reviewed-by: Ralph Campbell Reviewed-by: Christoph Hellwig Tested-by: Philip Yang --- v3 - Drop poison, looks like there are no new patches that will use this wrong (Christoph) --- mm/hmm.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/mm/hmm.c b/mm/hmm.c index 6f5dc6d568feb1..2ef14b2b5505f6 100644 --- a/mm/hmm.c +++ b/mm/hmm.c @@ -276,17 +276,11 @@ 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); } EXPORT_SYMBOL(hmm_mirror_unregister);