Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4158809ybb; Mon, 23 Mar 2020 14:52:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuikLeb40ndSiLi1lfQFeVhH3ESAKv/YxIVA7viAGElRJVoAJQB3AWk1Iq8mRSCNQOC0gjh X-Received: by 2002:a05:6808:43:: with SMTP id v3mr1171098oic.59.1585000364277; Mon, 23 Mar 2020 14:52:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585000364; cv=none; d=google.com; s=arc-20160816; b=VGSnITI3ikADlSAhAy39WbtrZ15GKt8QMECS5gANK6fdZihr+qP3QoND/QT/q22Rel japo5ZEmw7rNVwDUNN0eIjQTC4N764j/fAgY2FshSiIRLMMHVsYzW6y8tb+lhlzWokdZ 6eu9DHOB05WqoQz9K+SQrYYr58A8mdf0CdhdRq3ezYAlzm76vJJB0TE9NcqEMvoatCRs fEomqHKVoRNXO+WScABOdeGX/Es75JpgHfMJeohLHPBV786s6eFqe/0irVvBYz0OWHom tH1bqCll5v5iSrkmuZqjbI+H+l5QH7L6Sj8X6c4XZYwREKYDveGtD0eLNmyVuwRqcCHP 7NvQ== 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-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=zzaojujfcls2hgFyVUn0hD1Rb+7tZyy+TgUJhbpUoN0=; b=dMyJujD+bWJtqUm6n8nh4z+0dqv63dJDqzTPSl1gXMLFYHRYzKWYPH6GDNgbXbUZ2T mSwuySunAQhEZL8Gj4WWq1UC3VI7l5ZR+AjOo/h7fjhJX/sxS4WxIWw9De3TEWc8fvXQ W7KEZ+rIQpO3voOmSlRv1kEcwrR1NwrJN2h/DvxZ9F3qWRNRr3FmiXnjwEQn0aB8L27z GfdIP249iUWlKI8S6mZEcz6AQXlF8lGZoG47lgFzqssMwYzytKmFqb1CasoZbo2Wmlwq hwLxsbVa0vKgfs84tyZpd/bc+CYwY2qlkbcQbi6dqex+ueeKowRw5JLpPpoR0TIkt2Eo 3Uhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=tWTwtLci; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l16si8740070oti.106.2020.03.23.14.52.30; Mon, 23 Mar 2020 14:52:44 -0700 (PDT) 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; dkim=pass header.i=@linaro.org header.s=google header.b=tWTwtLci; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727031AbgCWVwJ (ORCPT + 99 others); Mon, 23 Mar 2020 17:52:09 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39583 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725897AbgCWVwJ (ORCPT ); Mon, 23 Mar 2020 17:52:09 -0400 Received: by mail-pf1-f195.google.com with SMTP id d25so8174336pfn.6 for ; Mon, 23 Mar 2020 14:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=zzaojujfcls2hgFyVUn0hD1Rb+7tZyy+TgUJhbpUoN0=; b=tWTwtLciVWGSxsbK51pBsm7+vZ073MLGRYvTY2C4gVsjjvEfn14hy7mCtlIsWT+LvQ al5phEEv8sdIIHJnFOjBu5CNIfygJVjQbwKif/nBhzkXYzPt2NeARsXaQbO7sHjYl7Ho IyuMyLSDe76UZsuPAvnYEFVGKNVGSkygCw+8o5OXo9RGlOSzkscK/JydAc5DUTMZO83W 03ohm0vE/DAPjcuZXljtjSbkdPHLTIyQmiBH6KTiDrfaisDWAPIrUN0bK7hUee01IuaS 2vh5bPwOmBCgwlmBoPM7NeRT3ejSr2KPgaJ3H/+g6hW07PbV15/ZheZ3OF+7xCrlsE1Y pXqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=zzaojujfcls2hgFyVUn0hD1Rb+7tZyy+TgUJhbpUoN0=; b=YCVe5XP7Cyr/qPA3EQK3EYOA2m9HZCdFKW/ldCQKN111NSLJu9Vgh5diYszXNG7KxU TYc3vr2wWov2Ae3JUIcpgrKyWhWd9w0CedItF0rEziGWGuH8xk5OTlLw+L+hkL6KjpW6 jmhET2bQgOwnieM5mqzZRBqHTuP15odwWGCmSX9/fzqxvz2JRVS7eixnyS7UFzQ0sen3 sHnj/6Pot3dCSyrzMN8Z7LftJyJOc7yVeVU0zhFMXk3Iir6QcBs0OzK1m0G0ZXPSvd0r jW1yGHGGPIKePwzGTBvlR51ZFvUOLkVqtOgqiX4L/eXrt2zSUiAGwoTzOy+46Go6bhZ0 tkaQ== X-Gm-Message-State: ANhLgQ3N7R9otMucTo9y+JOvB/GV8g8vKY6MYbq110qy9eDgpxgwTV/1 gN+4OpnXID6DRitdsQiGdwOl+A== X-Received: by 2002:a63:ec50:: with SMTP id r16mr25369318pgj.274.1585000327853; Mon, 23 Mar 2020 14:52:07 -0700 (PDT) Received: from xps15 (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id j12sm5499008pgs.0.2020.03.23.14.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Mar 2020 14:52:07 -0700 (PDT) Date: Mon, 23 Mar 2020 15:52:05 -0600 From: Mathieu Poirier To: Bjorn Andersson Cc: Andy Gross , Ohad Ben-Cohen , linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 1/4] remoteproc: Traverse rproc_list under RCU read lock Message-ID: <20200323215205.GA30464@xps15> References: <20200310063817.3344712-1-bjorn.andersson@linaro.org> <20200310063817.3344712-2-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200310063817.3344712-2-bjorn.andersson@linaro.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 09, 2020 at 11:38:14PM -0700, Bjorn Andersson wrote: > In order to be able to traverse the mostly read-only rproc_list without > locking during panic migrate traversal to be done under rcu_read_lock(). > > Mutual exclusion for modifications of the list continues to be handled > by the rproc_list_mutex and a synchronization point is added before > releasing objects that are popped from the list. > > Signed-off-by: Bjorn Andersson > --- > > Change v3: > - New patch > > drivers/remoteproc/remoteproc_core.c | 13 ++++++++----- > 1 file changed, 8 insertions(+), 5 deletions(-) > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > index 097f33e4f1f3..f0a77c30c6b1 100644 > --- a/drivers/remoteproc/remoteproc_core.c > +++ b/drivers/remoteproc/remoteproc_core.c > @@ -1854,8 +1854,8 @@ struct rproc *rproc_get_by_phandle(phandle phandle) > if (!np) > return NULL; > > - mutex_lock(&rproc_list_mutex); > - list_for_each_entry(r, &rproc_list, node) { > + rcu_read_lock(); > + list_for_each_entry_rcu(r, &rproc_list, node) { > if (r->dev.parent && r->dev.parent->of_node == np) { > /* prevent underlying implementation from being removed */ > if (!try_module_get(r->dev.parent->driver->owner)) { > @@ -1868,7 +1868,7 @@ struct rproc *rproc_get_by_phandle(phandle phandle) > break; > } > } > - mutex_unlock(&rproc_list_mutex); > + rcu_read_unlock(); > > of_node_put(np); > > @@ -1925,7 +1925,7 @@ int rproc_add(struct rproc *rproc) > > /* expose to rproc_get_by_phandle users */ > mutex_lock(&rproc_list_mutex); > - list_add(&rproc->node, &rproc_list); > + list_add_rcu(&rproc->node, &rproc_list); > mutex_unlock(&rproc_list_mutex); > > return 0; > @@ -2140,9 +2140,12 @@ int rproc_del(struct rproc *rproc) > > /* the rproc is downref'ed as soon as it's removed from the klist */ > mutex_lock(&rproc_list_mutex); > - list_del(&rproc->node); > + list_del_rcu(&rproc->node); > mutex_unlock(&rproc_list_mutex); > > + /* Ensure that no readers of rproc_list are still active */ > + synchronize_rcu(); > + Please add linuc/rculist.h to include the RCU API. With that: Reviewed-by: Mathieu Poirier > device_del(&rproc->dev); > > return 0; > -- > 2.24.0 >