Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp1978686imm; Thu, 7 Jun 2018 03:31:48 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJiiPKjNu6VvudGSFA1newNh3xuXHM390pa/Me9tIN85SMMn5UtpdWrGfJbHSQRd2G+F076 X-Received: by 2002:a65:6252:: with SMTP id q18-v6mr1141823pgv.106.1528367508652; Thu, 07 Jun 2018 03:31:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528367508; cv=none; d=google.com; s=arc-20160816; b=keX7LKT2RZi289eqjnMcN4uz+1uKbq4aISyT744QB9h1dEeKd1bc28w46pwmctxsIw r9/w90vOHHDXo5q8jintAvBrVRM1WN7hT0sSDIuqVHZwyA6ZtXE9PvuCpxvsTidJa8uE ySZvcXEfE0Un+tbzcWheL9fe+fne/sxzNXmT2uBxi37ypdC0RZAlw/4lehHSPuyVVby2 E5kM2oJBOj9NyA/Vx1n71k5Kz/HI3hE1NtSHJ6vzk63fDmr+TE271OYMpPFa1IAGnR1m BU8WdnLDRQDhganv4tErULYD1NG+aqQITA9qfAo2rGrmEMIGj0VWzzPkxWup9PGIlXSt RI3g== 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:arc-authentication-results; bh=3tOr9JOO+0Mtd394tomMf1f2X/hf+LRJ/MxM5qYkeV0=; b=eFKdTB8kmTRtSF5sP2Z8EubWuWlIKG/TeE18uzumxXOAbCpI80OwX4fikF26HWb1cL JGjNQ2EIpwOuf3vHvIJ1MZwCrWkb3DyzIyEv+F5fr+HDcBJ1vWeoG+QCPR2ZHkG2BAVD bFry3orD+Uc07AbqYIV/lGV5kGEPueswyzPAKhd72e7uSJY+b/BE2QbKwj4gy7ZjddnY pZ4cwge8LH54tAocEIrrwUKCEGneoght9Vy6j4iRTqwD+7Cf5uxfw5jPAugaBnygQxsC 9CdqpJJXCFkY8pltvGSDBzv6u4TL51xcrufxJBPZ/vMg55y6jAePZ72TznZVlHuTNZQQ HjvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tDm2DiyR; 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 t17-v6si27629404pgb.465.2018.06.07.03.31.34; Thu, 07 Jun 2018 03:31:48 -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=@kernel.org header.s=default header.b=tDm2DiyR; 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 S1753630AbeFGJxs (ORCPT + 99 others); Thu, 7 Jun 2018 05:53:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:45568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751681AbeFGJxr (ORCPT ); Thu, 7 Jun 2018 05:53:47 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 48D9520660; Thu, 7 Jun 2018 09:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1528365227; bh=8ck2zvA/fGx8go5b7rwR18uoD2jvUo5OqPbkEjNwxfI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tDm2DiyRRWAoBPoeYGMQilWbgM0Qf6JcQcEROyXyRWsTauJtm7XwbLEnm6fZxHfc+ kZWo34geE76Gr60dx9cQXX3b0PV+0xUjnmWY6+CGtLXmCHRnlnob26Ll7cz8VzgFZ/ XWbFLnhEKrI3vuOEYD3D3pdZc35eZpXeMmyXeFx8= Date: Thu, 7 Jun 2018 11:53:22 +0200 From: Greg Kroah-Hartman To: Suzuki K Poulose Cc: Kim Phillips , 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 Subject: Re: [PATCH v4 05/14] coresight: get/put module in coresight_build/release_path Message-ID: <20180607095322.GA26174@kroah.com> References: <20180605210710.22227-1-kim.phillips@arm.com> <20180605210710.22227-6-kim.phillips@arm.com> <20180606082422.GB19727@kroah.com> <20180606155501.704583e1412996a1a2c6fa61@arm.com> <20180607083401.GE16651@kroah.com> <3219276b-2703-bc30-92e1-bae80cdc5901@arm.com> <20180607091353.GA20438@kroah.com> <2f8d233e-8847-ce3d-3a5b-06b175e3944b@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2f8d233e-8847-ce3d-3a5b-06b175e3944b@arm.com> User-Agent: Mutt/1.10.0 (2018-05-17) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 07, 2018 at 10:32:21AM +0100, Suzuki K Poulose wrote: > On 06/07/2018 10:13 AM, Greg Kroah-Hartman wrote: > > On Thu, Jun 07, 2018 at 10:04:33AM +0100, Suzuki K Poulose wrote: > > > Hi Greg, > > > > > > On 06/07/2018 09:34 AM, Greg Kroah-Hartman wrote: > > > > On Wed, Jun 06, 2018 at 03:55:01PM -0500, Kim Phillips wrote: > > > > > On Wed, 6 Jun 2018 10:46:36 +0100 > > > > > Suzuki K Poulose wrote: > > > > > > > > > > > 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? > > > > > > The user doesn't have an explicit refcount on the individual components > > > in a trace session. So, when a trace session is in progress, it is as > > > good as having a "file" open on each component that is part of the > > > active trace session. So, we don't want the driver to be removed when > > > the component is being used in the trace collection. > > > > Why not? What's wrong with that happening and then the trace collection > > starts failing with -ENODEV or something? > > May be I am missing something here. Can we allow the driver to be removed > when one of its device is "turned ON" and we need the same > driver to "turn it OFF" when the session ends ? To make a better > comparison : > > Can we unload a usb_mass_storage module when a USB disk(which uses the > module driver) is mounted and is being used ? I believe, the module > will eventually get unloaded when we unmount the disk, if someone did > a unload. No, mount causes the module count to be incrememted. Mount and "open/close" are the old-school way of doing module reference counting. Look at how network drivers work today, you can unload any network driver even if there is a valid network connection "up and running" attached to it. It just gets torn down when that request happens. > We have a similar situation here. The only difference is the driver is > referenced only when one of its device is in a trace session. I understand, I'm saying that you have to be very careful when messing around with module reference counts to get it correct and perhaps you should just change your design to not care about module reference counts at all, like networking did 15+ years ago. Let's learn from the good examples in our past (like networking), and not like the older bad examples (like mount/files). > > Remember, removing a kernel module is something that only happens very > > rarely, and is an explicit choice by someone with root permissions. If > > you want to remove that module, it should be able to go, as you know > > what you are doing at that point in time. > > Right, but when a device is "in use" can we do that ? I thought the user > will get a module is in use or busy, error. Try it on networking today :) > > Don't try to "protect the user from themselves" here, they want to shoot > > their foot, make it hurt if they are aiming it there :) > > > > The module_get/put added here are only triggered when we start a trace > session, where we build a path for the current session from the configured > "source" to the configured "sink" and the path is destroyed > at the end of the trace session. i.e, the path is not a permanent thing. > It is constructed per session. So it is perfectly possible to remove a > device in between trace sessions. That's fine, but again, just be careful to get this correct. The patch I reviewed did not seem to do that. thanks, greg k-h