All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oren Laadan <orenl-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
To: "Serge E. Hallyn" <serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: Re: [RFC PATCH 11/17] define function to print error messages to user log
Date: Wed, 28 Oct 2009 17:50:45 -0400	[thread overview]
Message-ID: <4AE8BCB5.4030406@librato.com> (raw)
In-Reply-To: <20091028205424.GA27394-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>



Serge E. Hallyn wrote:
> Quoting Matt Helsley (matthltc-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org):
>>> @@ -401,6 +409,9 @@ char *ckpt_generate_fmt(struct ckpt_ctx *ctx, char *fmt)
>>>  		case 'E':
>>>  			len += sprintf(format+len, "[%s]", "err %d");
>>>  			break;
>>> +		case 'C': /* count of bytes read/written to checkpoint image */
>>> +			len += sprintf(format+len, "[%s]", "pos %d");
>>> +			break;
>> Instead we could always output ckpt->total and then we wouldn't need %(C). I
>> suspect it's such a useful piece of information that it'll be repeated
>> in many/all format strings eventually.
> 
> Yes, likewise %(T).  If that's what we want to do.

I agree. For the cases when there is not task, can put "none"

> 
> Should we discuss here what we want an entry to look like?  For both
> ckpt_write_err (to the checkpoint image) and ckpt_error()?
> 

Yes please !

>>>  		case 'O':
>>>  			len += sprintf(format+len, "[%s]", "obj %d");
>>>  			break;
>>> @@ -435,6 +446,51 @@ char *ckpt_generate_fmt(struct ckpt_ctx *ctx, char *fmt)
>>>  	return format;
>>>  }
>>>
>>> +void ckpt_log_error(struct ckpt_ctx *ctx, char *fmt, ...)
>>> +{
>>> +	mm_segment_t fs;
>>> +	struct file *file;
>>> +	int count;
>>> +	va_list ap, aq, az;
>>> +	char *format;
>>> +	char buf[200], *bufp = buf;
>> I believe this buffer is too big for a kernel stack -- especially
>> for ckpt_log_error() which might be invoked "deep" in
>> the kernel stack.
> 
> 200 bytes?  Well, I guess I can try with 50 which still may often be
> enough.

How about using a dedicated buffer on @ctx for that ?

> 
>>> +	if (!ctx || !ctx->logfile)
>>> +		return;
>>> +	file = ctx->logfile;
>>> +
>>> +	va_start(ap, fmt);
>>> +	format = ckpt_generate_fmt(ctx, fmt);
>>> +	va_copy(aq, ap);
>>> +	va_copy(az, ap);
>>> +	/* I'm not clear here - can I re-use aq, or do i need
>>> +	 * a third copy? */
>> I'm no varargs expert but I have re-read the man page and
>> seen a purported snippet of the standard. :)
>>
>> I think you need a third copy operation but you may only need
>> two va_lists so long as you do a va_end before the next va_copy:
>>
>> 	va_copy(aq, ap);
>> 	... <use aq> ...
>> 	va_end(aq);
>> 	va_copy(aq, ap);
>> 	... <use aq> ...
>> 	va_end(aq);
>> 	...
>> 	va_end(ap); 
>>
>> Based on my reading it sounded like some arch/ABIs require space
>> proportional to the number of arguments for each un-va_end-ed copy.
> 
> Ok, I'll do that, thanks.
> 
>>> +	count = vsnprintf(bufp, 200, format ? : fmt, aq);
>> BTW -- I think you can use snprintf() without the buffer and length
>> arguments if you just need the length calculated. Perhaps the same
>> is possible with vsnprintf():
>>
>> 	count = vsnprintf(NULL, 0, format ? : fmt, aq);
>>
>> If that works with vsnprintf() too then you could get rid of the
>> stack buf and always kmalloc the space..
> 
> Hmm, yeah...  though i don't know that I *want* to always kmalloc
> the space :)  It does look like it should work (though no comment
> to that effect), but there is no speed advantage, save a bit of
> memcpy (vs. always having a kmalloc).

Again, a dedicated buffer on @ctx will be helpful here.

Oren.

  parent reply	other threads:[~2009-10-28 21:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-27 22:46 [RFC PATCH 0/17] Introduce ckpt_error Serge Hallyn
     [not found] ` <1256683587-23961-1-git-send-email-serge-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-27 22:46   ` [RFC PATCH 01/17] ckpt_write_err: use single format with %(T) style tokens Serge Hallyn
     [not found]     ` <1256683587-23961-2-git-send-email-serge-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-28 16:50       ` Matt Helsley
2009-10-27 22:46   ` [RFC PATCH 02/17] make ckpt_format_fmt non-static in checkpoint/sys.c Serge Hallyn
     [not found]     ` <1256683587-23961-3-git-send-email-serge-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-28 16:53       ` Matt Helsley
     [not found]         ` <20091028165317.GS31446-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-10-28 18:04           ` Serge E. Hallyn
     [not found]             ` <20091028180418.GB19554-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-28 18:31               ` Serge E. Hallyn
2009-10-28 22:21           ` Serge E. Hallyn
2009-10-27 22:46   ` [RFC PATCH 03/17] ckpt_write_err update arch/x86/mm/checkpoint.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 04/17] ckpt_write_err update checkpoint/checkpoint.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 05/17] ckpt_write_err update checkpoint/files.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 06/17] ckpt_write_err update checkpoint/memory.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 07/17] ckpt_write_err update checkpoint/objhash.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 08/17] ckpt_write_err update checkpoint/process.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 09/17] ckpt_write_err update checkpoint/signal.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 10/17] ckpt_write_err update fs/eventpoll.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 11/17] define function to print error messages to user log Serge Hallyn
     [not found]     ` <1256683587-23961-12-git-send-email-serge-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-28 18:14       ` Matt Helsley
     [not found]         ` <20091028181415.GB14023-52DBMbEzqgQ/wnmkkaCWp/UQ3DHhIser@public.gmane.org>
2009-10-28 20:54           ` Serge E. Hallyn
     [not found]             ` <20091028205424.GA27394-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-28 21:50               ` Oren Laadan [this message]
     [not found]                 ` <4AE8BCB5.4030406-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-28 22:12                   ` Serge E. Hallyn
     [not found]                     ` <20091028221208.GA30227-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-28 22:31                       ` Oren Laadan
     [not found]                         ` <4AE8C639.6090105-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-29  0:12                           ` Serge E. Hallyn
     [not found]                             ` <20091029001223.GA1463-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2009-10-29  0:44                               ` Oren Laadan
     [not found]                                 ` <4AE8E578.4030300-RdfvBDnrOixBDgjK7y7TUQ@public.gmane.org>
2009-10-29  4:23                                   ` Serge E. Hallyn
     [not found]                                     ` <20091029042304.GA9005-A9i7LUbDfNHQT0dZR+AlfA@public.gmane.org>
2009-10-29 16:02                                       ` Oren Laadan
2009-10-27 22:46   ` [RFC PATCH 12/17] use ckpt_error in checkpoint/restart.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 13/17] ckpt_error in checkpoint/files.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 14/17] ckpt_error in checkpoint/process.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 15/17] ckpt_error in ipc/checkpoint_msg.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 16/17] ckpt_error in ipc/checkpoint_sem.c Serge Hallyn
2009-10-27 22:46   ` [RFC PATCH 17/17] ckpt_error in ipc/checkpoint_shm.c Serge Hallyn

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=4AE8BCB5.4030406@librato.com \
    --to=orenl-rdfvbdnroixbdgjk7y7tuq@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=serue-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    /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.