All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Monakhov <dmonakhov@openvz.org>
To: Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	axboe@kernel.dk, viro@zeniv.linux.org.uk, dm-devel@redhat.com
Subject: Re: [PATCH 1/7] lib/vsprintf: add %*pg format specifier
Date: Wed, 01 Apr 2015 11:43:35 +0300	[thread overview]
Message-ID: <87r3s4tf0o.fsf@openvz.org> (raw)
In-Reply-To: <1427821576.10376.29.camel@perches.com>

[-- Attachment #1: Type: text/plain, Size: 2524 bytes --]

Joe Perches <joe@perches.com> writes:

> On Tue, 2015-03-31 at 20:01 +0400, Dmitry Monakhov wrote:
>> This allow to directly print block_device name.
>> Currently one should use bdevname() with temporal char buf[BDEVNAME_SIZE].
>> This is very ineffective because bloat stack usage for deep IO call-traces
> []
>> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> []
>> @@ -610,6 +613,23 @@ char *dentry_name(char *buf, char *end, const struct dentry *d, struct printf_sp
>>  	return buf;
>>  }
>>  
>> +#ifdef CONFIG_BLOCK
>> +static noinline_for_stack
>> +char *bdev_name(char *buf, char *end, struct block_device *bdev,
>> +		struct printf_spec spec, const char *fmt)
>> +{
>> +	struct gendisk *hd = bdev->bd_disk;
>
> Can you please use the same form as dentry_name and
> dereference the pointer in vsprintf not here as below.
Im not sure I've got your comments. Please elaborate.
As far as I can see vsprintf->pointer looks like follows:
       dentry_name
        case 'd':
                        return dentry_name(buf, end, ptr, spec, fmt);
                        
No any special dereference logic here. Later dentry ptr dereferenced
and accessed inside dentry_name as usual. Same logic works for Ipv[46]
format specifiers.

***Copied comment from next email:
>   Perhaps it would be useful to update the disk_name/bdevname
>   functions to take a buffer length along with the char * so
>   that buffer overflows could not occur.
disk_name() use snprintf which is bad candidate to use inside vsprintf.
>
>   That would also allow this function to use bdevname directly.
I'll change bdevname() to use "%pg" format specifier in order to
eliminate code duplication.
>
>> @@ -1404,6 +1424,8 @@ int kptr_restrict __read_mostly;
>>   *           (default assumed to be phys_addr_t, passed by reference)
>>   * - 'd[234]' For a dentry name (optionally 2-4 last components)
>>   * - 'D[234]' Same as 'd' but for a struct file
>> + * - 'g' For block_device name (gendisk + partition number)
>> +
>>   *
>>   * Note: The difference between 'S' and 'F' is that on ia64 and ppc64
>>   * function pointers are really function descriptors, which contain a
>> @@ -1552,6 +1574,11 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
>>  		return dentry_name(buf, end,
>>  				   ((const struct file *)ptr)->f_path.dentry,
>>  				   spec, fmt);
>> +#ifdef CONFIG_BLOCK
>> +	case 'g':
>> +		return bdev_name(buf, end, ptr, spec, fmt);
>> +#endif
>> +
>>  	}

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 472 bytes --]

  parent reply	other threads:[~2015-04-01  8:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-31 16:01 [RFC] [PATCH 0/7] fs: add blkdev name format specifier Dmitry Monakhov
2015-03-31 16:01 ` Dmitry Monakhov
2015-03-31 16:01 ` [PATCH 1/7] lib/vsprintf: add %*pg " Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-03-31 17:06   ` Joe Perches
2015-03-31 17:37     ` Joe Perches
2015-04-01  8:43     ` Dmitry Monakhov [this message]
2015-03-31 16:01 ` [PATCH 2/7] fs: use gendisk->disk_name where possible Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-03-31 16:01 ` [PATCH 3/7] block: use block_device name vsprintf helper Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-03-31 16:01 ` [PATCH 4/7] fs: " Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-03-31 16:01 ` [PATCH 5/7] md: " Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-03-31 16:01 ` [PATCH 6/7] block/partitions: " Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-04-02  5:58   ` Sergey Senozhatsky
2015-03-31 16:01 ` [PATCH 7/7] drivers: " Dmitry Monakhov
2015-03-31 16:01   ` Dmitry Monakhov
2015-03-31 16:43 ` [RFC] [PATCH 0/7] fs: add blkdev name format specifier Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r3s4tf0o.fsf@openvz.org \
    --to=dmonakhov@openvz.org \
    --cc=axboe@kernel.dk \
    --cc=dm-devel@redhat.com \
    --cc=joe@perches.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.