Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp592344imm; Wed, 6 Jun 2018 02:47:23 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIOb0SF3OSyWKAHLrLACOLwQonlh+YDa9I6BVfaFqYCTQuomYhMGdP8mL/MqirzzfT0kd/m X-Received: by 2002:a65:4b82:: with SMTP id t2-v6mr1956123pgq.175.1528278443049; Wed, 06 Jun 2018 02:47:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528278443; cv=none; d=google.com; s=arc-20160816; b=x3fBbd4nxPSjZNmON+EYFwyYXSCHOVD/IfQf+LY5pHx+Q5ED+v43wu+oJpwB+01Zdu oDcHVNYgcIXRY1BRapC2bjP8DFTJXDFYqNmjZ32/HzlmrDZHet2ISX41wT/PF169rwiZ vltPeURp+LV4dYGoMzf9MoG+DHGnPDNfWlsoeS3s+fN9DJaFgHeV1IGJv6Gr8Z628WaB 8H+VZZWuq6Qntp8xrjJ+V1mHvldyJkp+RD5KTroOWVTAdu4ToifJsdD3BD2FmiuIcYeZ YTeGOzr8dfHfbd51KmLNaMt9z44BlU+KZBPjuta1wtgt3xXSq/HXu7mwkEtkVwA6LH8k jbwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=vVotDJwzXfdqaGLVQpYbi9vIPW1rywmdzgEJAA8csOw=; b=jTDuv+ykEu4JjhceddT1O6D/aKqA3b1MqK6A4Mw/vatdQtipGL/+vgMt5UyMF8ACW7 fOOAGj4TSnBMGOLsNSOLLrUJRt6q07R1qkSSY8tLV8CsE2o7PVWjQ9dmJ6fBnpFiu/ik 5iub41LkiaT8fMr7hC6pQQJp4CFGpZ6kyOY6d/Sp8EMycZm1gr+ysW9/o1DDYSif5FGz b1Qz4EdRO2LRhVO0I7SCZGUtFBlobSvVagAmz9ERRWt6RIvu/Rzz9MrY6piBXEQv+z7I sKkfrjK+pbhzjRO4StyYtq3YOcMPZHOi9dAs2R/obQnhzptpGgR6hSyGMqnN+ITUn48u QonQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j29-v6si15275233pga.195.2018.06.06.02.47.08; Wed, 06 Jun 2018 02:47:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932263AbeFFJqj (ORCPT + 99 others); Wed, 6 Jun 2018 05:46:39 -0400 Received: from foss.arm.com ([217.140.101.70]:38618 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750794AbeFFJqi (ORCPT ); Wed, 6 Jun 2018 05:46:38 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5BEA715AB; Wed, 6 Jun 2018 02:46:38 -0700 (PDT) Received: from [10.37.8.39] (unknown [10.37.8.39]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F31193F557; Wed, 6 Jun 2018 02:46:32 -0700 (PDT) Subject: Re: [PATCH v4 05/14] coresight: get/put module in coresight_build/release_path To: Greg Kroah-Hartman , Kim Phillips Cc: Mathieu Poirier , Leo Yan , Alexander Shishkin , Alex Williamson , Andrew Morton , David Howells , Eric Auger , Eric Biederman , Gargi Sharma , Geert Uytterhoeven , Kefeng Wang , Kirill Tkhai , Mike Rapoport , Oleg Nesterov , Pavel Tatashin , Rik van Riel , Robin Murphy , Russell King , Thierry Reding , Todd Kjos , Randy Dunlap , linux-arm-kernel , Linux Kernel Mailing List References: <20180605210710.22227-1-kim.phillips@arm.com> <20180605210710.22227-6-kim.phillips@arm.com> <20180606082422.GB19727@kroah.com> From: Suzuki K Poulose Message-ID: Date: Wed, 6 Jun 2018 10:46:36 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180606082422.GB19727@kroah.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06/06/2018 09:24 AM, Greg Kroah-Hartman wrote: > On Tue, Jun 05, 2018 at 04:07:01PM -0500, Kim Phillips wrote: >> Increment the refcnt for driver modules in current use by calling >> module_get in coresight_build_path and module_put in release_path. >> >> This prevents driver modules from being unloaded when they are in use, >> either in sysfs or perf mode. > > Why does it matter? Shouldn't you be allowed to remove any module at > any point in time, much like a networking driver? > > >> >> Cc: Mathieu Poirier >> Cc: Leo Yan >> Cc: Alexander Shishkin >> Cc: Randy Dunlap >> Cc: Suzuki K Poulose >> Cc: Greg Kroah-Hartman >> Cc: Russell King >> Signed-off-by: Kim Phillips >> --- >> drivers/hwtracing/coresight/coresight.c | 9 +++++++++ >> 1 file changed, 9 insertions(+) >> >> diff --git a/drivers/hwtracing/coresight/coresight.c b/drivers/hwtracing/coresight/coresight.c >> index 338f1719641c..1c941351f1d1 100644 >> --- a/drivers/hwtracing/coresight/coresight.c >> +++ b/drivers/hwtracing/coresight/coresight.c >> @@ -465,6 +465,12 @@ static int _coresight_build_path(struct coresight_device *csdev, >> >> node->csdev = csdev; >> list_add(&node->link, path); >> + >> + if (!try_module_get(csdev->dev.parent->driver->owner)) { > > What is to keep parent->driver from going away right here? What keeps > parent around? This feels very fragile to me, I don't see any locking > anywhere around this code path to try to keep things in place. You're right. We do have coresight_mutex, which is held across the build path and the csdev is removed when a device is unregistered. However, I see that we don't hold the mutex while removing the connections from coresight_unregister(). Holding the mutex should protect us from the csdev being removed, while we build the path. And while we are at this, I also realised that we hold references to the parent devices for each connection (via bus_find_device() from of_coresight_get_endpoint_device()), while parsing the platform data, which is never released. Thanks Suzuki > > thanks, > > greg k-h >