Received: by 10.223.185.116 with SMTP id b49csp4112576wrg; Tue, 6 Mar 2018 10:01:02 -0800 (PST) X-Google-Smtp-Source: AG47ELtEGpsvDGgqoSIy+SAQdK0CZhN0oZDDf50yrjLzHtKMP1kZFTpN4pY58uw7UHcqcKRoqzUA X-Received: by 10.98.248.7 with SMTP id d7mr19843701pfh.117.1520359262093; Tue, 06 Mar 2018 10:01:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520359262; cv=none; d=google.com; s=arc-20160816; b=IUzRR5cYZ75WrPp8eMr7e7o5u4PJbfRYcqLBXAk2IcrA/DKyYNpT07vXue0oBwA+OY dRVLknJvSqux65IMDTFglZ10HDN4Yrs989BbCvMBF2tu3g8+WbAQ/NFAAfX9sFYlHTyT Elbej86Yz3kX2/S0XNo95gB4L4KcVlIMzetzxaxSQkUlOJxqiOxdzqKwvFvZqpJ8VStV cRO0ZKyltLy8JddBKqZC1tP9kTw7u1hoSBsCox6U2yllPWkeEq+vYRVBykd7PpiDEARt 3eGES84hYIKJpIItZ8TtNvpirc333Y7EE5FxHRo4WrG+JuUO/wi+9uzHSD6/L7f27dTS c8hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date :arc-authentication-results; bh=66+c/J2hyZsgCVcaPwZvosC7BYopPFsw9vVhK11Vysw=; b=cYx3WExW3EALMFTtpMSMij1Z0AXFoUskSDI9wgxec3EyiTq58dgAx/BaIt24xEe905 4g76hIe80EGBWJDjYkydmku2UQK0esJjeeEPSeHh9p29ZgQLpUs4ym+hP2hb0goVNWdL 7IYWNzIlhVpR1sd4MQ9ua6GNAYvHqEYBVyXH4Rks9L52BmsUBBNDBU9encHszLXX2nKr SNGszsoKSdkTk0UY4e5r8yc0HY6gPBXLBsUZcaNdnFmagUvDsjgO/WG7XB8jMjOMUUhw BsPDfEoiLuYLbBjzL3lRBQiWAzLecf9EljyweikkVBLi7h+w0WUnMDJ/kTT+hM3oP4nj Z9sw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f66si11613246pfd.138.2018.03.06.10.00.46; Tue, 06 Mar 2018 10:01:02 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753871AbeCFR7w (ORCPT + 99 others); Tue, 6 Mar 2018 12:59:52 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:38582 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753598AbeCFR7v (ORCPT ); Tue, 6 Mar 2018 12:59:51 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9FE5D4023156; Tue, 6 Mar 2018 17:59:50 +0000 (UTC) Received: from redhat.com (ovpn-123-184.rdu2.redhat.com [10.10.123.184]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B5B9B2144B20; Tue, 6 Mar 2018 17:59:49 +0000 (UTC) Date: Tue, 6 Mar 2018 12:59:48 -0500 From: Jerome Glisse To: Tejun Heo Cc: torvalds@linux-foundation.org, jannh@google.com, paulmck@linux.vnet.ibm.com, bcrl@kvack.org, viro@zeniv.linux.org.uk, kent.overstreet@gmail.com, security@kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org Subject: Re: [PATCH 4/7] HMM: Remove superflous RCU protection around radix tree lookup Message-ID: <20180306175948.GA4791@redhat.com> References: <20180306172657.3060270-1-tj@kernel.org> <20180306173316.3088458-1-tj@kernel.org> <20180306173316.3088458-4-tj@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20180306173316.3088458-4-tj@kernel.org> User-Agent: Mutt/1.9.2 (2017-12-15) X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 06 Mar 2018 17:59:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Tue, 06 Mar 2018 17:59:50 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jglisse@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 06, 2018 at 09:33:13AM -0800, Tejun Heo wrote: > hmm_devmem_find() requires rcu_read_lock_held() but there's nothing > which actually uses the RCU protection. The only caller is > hmm_devmem_pages_create() which already grabs the mutex and does > superflous rcu_read_lock/unlock() around the function. > > This doesn't add anything and just adds to confusion. Remove the RCU > protection and open-code the radix tree lookup. If this needs to > become more sophisticated in the future, let's add them back when > necessary. > > Signed-off-by: Tejun Heo Reviewed-by: J?r?me Glisse > Cc: linux-mm@kvack.org > Cc: Linus Torvalds > --- > Hello, J?r?me. > > This came up while auditing percpu_ref users for missing explicit RCU > grace periods. HMM doesn't seem to depend on RCU protection at all, > so I thought it'd be better to remove it for now. It's only compile > tested. Good catch some left over of old logic. I have more cleanup queued up now that i am about to post nouveau patches to use all this. Thanks for fixing this. > > Thanks. > > mm/hmm.c | 12 ++---------- > 1 file changed, 2 insertions(+), 10 deletions(-) > > diff --git a/mm/hmm.c b/mm/hmm.c > index 320545b98..d4627c5 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -845,13 +845,6 @@ static void hmm_devmem_release(struct device *dev, void *data) > hmm_devmem_radix_release(resource); > } > > -static struct hmm_devmem *hmm_devmem_find(resource_size_t phys) > -{ > - WARN_ON_ONCE(!rcu_read_lock_held()); > - > - return radix_tree_lookup(&hmm_devmem_radix, phys >> PA_SECTION_SHIFT); > -} > - > static int hmm_devmem_pages_create(struct hmm_devmem *devmem) > { > resource_size_t key, align_start, align_size, align_end; > @@ -892,9 +885,8 @@ static int hmm_devmem_pages_create(struct hmm_devmem *devmem) > for (key = align_start; key <= align_end; key += PA_SECTION_SIZE) { > struct hmm_devmem *dup; > > - rcu_read_lock(); > - dup = hmm_devmem_find(key); > - rcu_read_unlock(); > + dup = radix_tree_lookup(&hmm_devmem_radix, > + key >> PA_SECTION_SHIFT); > if (dup) { > dev_err(device, "%s: collides with mapping for %s\n", > __func__, dev_name(dup->device)); > -- > 2.9.5 >