From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754980AbbBOWUL (ORCPT ); Sun, 15 Feb 2015 17:20:11 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:57455 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750866AbbBOWUJ (ORCPT ); Sun, 15 Feb 2015 17:20:09 -0500 Date: Sun, 15 Feb 2015 23:20:06 +0100 From: Markus Pargmann To: Joe Perches Cc: nbd-general@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH 6/9] nbd: Restructure debugging prints Message-ID: <20150215222006.GC28491@pengutronix.de> References: <1423774657-12748-1-git-send-email-mpa@pengutronix.de> <1423774657-12748-7-git-send-email-mpa@pengutronix.de> <1423775328.15343.38.camel@perches.com> <20150213095850.GA10654@pengutronix.de> <1423821927.2795.3.camel@perches.com> <20150213112415.GD14438@pengutronix.de> <1423828086.2795.5.camel@perches.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="O3RTKUHj+75w1tg5" Content-Disposition: inline In-Reply-To: <1423828086.2795.5.camel@perches.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 23:05:01 up 25 days, 12:12, 34 users, load average: 2.67, 8.52, 5.03 User-Agent: Mutt/1.5.23 (2014-03-12) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::7 X-SA-Exim-Mail-From: mpa@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --O3RTKUHj+75w1tg5 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Feb 13, 2015 at 03:48:06AM -0800, Joe Perches wrote: > On Fri, 2015-02-13 at 12:24 +0100, Markus Pargmann wrote: > > On Fri, Feb 13, 2015 at 02:05:27AM -0800, Joe Perches wrote: > > > On Fri, 2015-02-13 at 10:58 +0100, Markus Pargmann wrote: > > > > On Thu, Feb 12, 2015 at 01:08:48PM -0800, Joe Perches wrote: > > > > > On Thu, 2015-02-12 at 21:57 +0100, Markus Pargmann wrote: > > > > > > dprintk has some name collisions with other frameworks and driv= ers. It > > > > > > is also not necessary to have these custom debug print filters.= Dynamic > > > > > > debug offers the same amount of filtered debugging. > > > > > >=20 > > > > > > This patch replaces all dprintks with dev_dbg(). It also remove= s the > > > > > > ioctl dprintk which prints the ingoing ioctls which should be > > > > > > replaceable by strace or similar stuff. > > > > >=20 > > > > > Perhaps add > > > > >=20 > > > > > #define nbd_dbg(nbd, fmt, ...) \ > > > > > dev_dbg(disk_to_dev((nbd)->disk), "%s: " fmt, \ > > > > > nbd->disk->disk_name, ##__VA_ARGS__) > > > >=20 > > > > I am not really happy with those custom debug print macros. What do= you > > > > think about an inline function 'nbd_to_dev' instead? > > >=20 > > > Wouldn't that change the output? > > > What would the output look like? > >=20 > > I meant a function that just translates struct nbd_device* to struct > > device*. That wouldn't change the output. > > > > > > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c > > > > > [] > > > > > > +static void nbd_end_request(struct nbd_device *nbd, struct req= uest *req) > > > > > > { > > > > > > int error =3D req->errors ? -EIO : 0; > > > > > > struct request_queue *q =3D req->q; > > > > > > unsigned long flags; > > > > > > =20 > > > > > > - dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->dis= k_name, > > > > > > - req, error ? "failed" : "done"); > > > > > > + dev_dbg(disk_to_dev(nbd->disk), "%s: request %p: %s\n", > > > > > > + req->rq_disk->disk_name, req, error ? "failed" : "done"); > > > > >=20 > > > > > so this becomes > > > > >=20 > > > > > nbd_dbg(nbd, "request %p: %s\n", > > > > > req, error ? "failed" : "done"); > > > >=20 > > > > so this would be: > > > > nbd_dbg(nbd_to_dev(nbd), "request %p: %s\n", > > > > req, error ? "failed" : "done"); > > >=20 > > > I don't see much value in that style, > > > but I don't manage the code either. > >=20 > > Oh sorry, I meant to write: > > dev_dbg(nbd_to_dev(nbd), "request %p: %s\n", > > req, error ? "failed" : "done"); > >=20 > > So the normal dev_dbg call is still there and the expression to get the > > device from a nbd_device struct is shorter. >=20 > Is nbd->disk->disk_name the same string as > disk_to_dev((nbd)->disk)->name? >=20 > What's the output of the conversion in this patch? Oh yes, thanks, that's twice the device name then. Will fix that. >=20 > - dprintk(DBG_BLKDEV, "%s: request %p: %s\n", req->rq_disk->disk_name, > - req, error ? "failed" : "done");=20 > + dev_dbg(disk_to_dev(nbd->disk), "%s: request %p: %s\n", > + req->rq_disk->disk_name, req, error ? "failed" : "done"); >=20 > Should this conversion be as you wrote above >=20 > dev_dbg(nbd_to_dev(nbd), "request %p: %s\n", > req, error ? "failed" : "done"); >=20 > If so, then there's probably not much use in a > custom nbd_dbg macro. >=20 > There is some value though in classifying blocks of > debugging output akin to the use of netif_msg_. >=20 > That is lost with these conversions. It is still possible to enable/disable particular dev_dbg calls using the dynamic debug interface. It is not as simple as the classification before but on the other hand it will probably not be used very often. dev_dbg() also allows enabling the debug output while the kernel is running. The previous dprintk() was only available when the kernel was compiled with "NDEBUG" defined. Best regards, Markus --=20 Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | --O3RTKUHj+75w1tg5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJU4RuWAAoJEEpcgKtcEGQQ4JkP/A4BPAfv18NypCp005Be8z47 XXGm9SXK9Q55y0MCaND5eOrHLN0RnTkHxAGFMq/4cx84KslvJefVlcoBaKwIQUrG nFdmOtClg/5wObnf7DtMKX1sqz69uprRAr4j/sKdr3WSd2vcvdyoMqc2yJO7/OFF WjPjc/57ywFfsW3cNYxJTYvJ818r8SEG8eKb1yBbaXhDFxSltZRt1Uao+FN8eN4/ OQdZ1T+bQ2LFEanLsbJe61fj7nLstKF5XW+Q+N01v8YM6ai+kjK6wwjLkfMEPkmy srFObQPuWamx8J6FIDwzCGl2YBWxuooJPTglXiozhtVfLhMA+4cvGNYGxRmzNZRr TmpLDxZSp3eGmIs6RNuWPOWqPV3nbVKg5azrl49iXwxGWgmOqwtDNxTdYGrgqZ9I 09lQZ+a8KdjdLprETRr1go5qEYz3WGx52kk/feBYduuOjx07Xx+M0BYiq9pNmnNt u38d9xK3Gu+YLDAOe7HFMFBq4Ru5hhqJgXhJQTRuhOQS6ijrxoRis/nSwaP/5KXw PUtZHTI30n4ljUz/eI7lVHHClEwbRWAivy+K2gCnDDZLfRMfMx0Itv2vpIZAnGBX IOBX8GSkEj00timgheCLtMbbFP47hJnMPxvf4CY3Kn5msc0O6RU4403Re+p3wLjL XxI5mlVeMy3aps9/3ThM =hWt/ -----END PGP SIGNATURE----- --O3RTKUHj+75w1tg5--