Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1739289

Re: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the schemata file

From "Luck, Tony" <tony.luck@intel.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the schemata file
Date 2017-09-25 23:40 +0200
Message-ID <utJgB-3Dz-3@gated-at.bofh.it> (permalink)
References <urcyt-41P-3@gated-at.bofh.it> <urcyu-41P-15@gated-at.bofh.it> <utCf7-7pv-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Mon, Sep 25, 2017 at 04:04:07PM +0200, Thomas Gleixner wrote:
> On Mon, 18 Sep 2017, Luck, Tony wrote:
> > @@ -208,14 +241,19 @@ ssize_t rdtgroup_schemata_write(struct kernfs_open_file *of,
> >  	char *tok, *resname;
> >  	int closid, ret = 0;
> >  
> > +	seq_buf_clear(&last_cmd_status);
> > +
> >  	/* Valid input requires a trailing newline */
> > -	if (nbytes == 0 || buf[nbytes - 1] != '\n')
> > +	if (nbytes == 0 || buf[nbytes - 1] != '\n') {
> > +		seq_buf_puts(&last_cmd_status, "no trailing newline\n");
> >  		return -EINVAL;
> > +	}
> >  	buf[nbytes - 1] = '\0';
> 
> In all other instances you access last_cmd_status within the
> rdtgroup_kn_lock_live() protected section, which also serializes the show()
> function via rdtgroup_mutex. Here you do it outside for obvious reasons,
> but that opens a can of evil worms ...

Indeed.

> Can you please provide and use two helpers - last_cmd_buf_clear() and
> last_cmd_buf_puts() - which both have a
> lockdep_assert_held(&rdtgroup_mutex) inside to make sure that we don't end
> up with unprotected access accidentally?

Sure. In progress. But I also need a last_cmd_printf(), which for some
reason is giving me grief.  In the header file I put:

+static inline void last_cmd_printf(const char *fmt, ...)
+{
+       va_list ap;
+
+       va_start(ap, fmt);
+       lockdep_assert_held(&rdtgroup_mutex);
+       seq_buf_printf(&last_cmd_status, fmt, ap);
+       va_end(ap);
+}

and use it like this:

+       last_cmd_printf("unknown/unsupported resource name '%s'\n", resname);

but the argument gets lost/mangled. Instead of the string that
should have appeared for the %s, I just get a \b

Also with nummeric arguments:

+               last_cmd_printf("mask %lx has non-consecutive 1-bits\n", val);

I get some kernel pointer looking value instead of "5":

	mask ffffa1ee62757c98 has non-consecutive 1-bits


Is there a limit on how many nested va_start()/va_end() can happen? Or is the
compiler confused because I made this "inline"? Or just a silly typo that I
can't see despite staring at it for a while?

-Tony

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC 0/5] x86/intel_rdt: Better diagnostics "Luck, Tony" <tony.luck@intel.com> - 2017-09-19 00:20 +0200
  [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the schemata file "Luck, Tony" <tony.luck@intel.com> - 2017-09-19 00:20 +0200
    Re: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the  schemata file Thomas Gleixner <tglx@linutronix.de> - 2017-09-25 16:10 +0200
      Re: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the  schemata file "Luck, Tony" <tony.luck@intel.com> - 2017-09-25 23:40 +0200
        RE: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the  schemata file "Luck, Tony" <tony.luck@intel.com> - 2017-09-26 00:20 +0200
        Re: [PATCH 2/5] x86/intel_rdt: Add diagnostics when writing the  schemata file Thomas Gleixner <tglx@linutronix.de> - 2017-09-26 00:20 +0200
  Re: [RFC 0/5] x86/intel_rdt: Better diagnostics Steven Rostedt <rostedt@goodmis.org> - 2017-09-19 03:20 +0200
  [PATCH 6/5] x86/intel_rdt: Add documentation for "info/last_cmd_status" "Luck, Tony" <tony.luck@intel.com> - 2017-09-20 01:20 +0200
  Re: [RFC 0/5] x86/intel_rdt: Better diagnostics Borislav Petkov <bp@suse.de> - 2017-09-21 14:10 +0200

csiph-web