public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: john stultz <johnstul@us.ibm.com>
To: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@elte.hu>,
	Thomas Gleixner <tglx@linutronix.de>,
	Daniel Walker <dwalker@fifo99.com>
Subject: Re: [patch 04/15] cleanup clocksource selection
Date: Fri, 14 Aug 2009 18:43:12 -0700	[thread overview]
Message-ID: <1250300592.8269.27.camel@localhost.localdomain> (raw)
In-Reply-To: <1250300540.8269.26.camel@localhost.localdomain>

On Fri, 2009-08-14 at 18:42 -0700, john stultz wrote:
> On Fri, 2009-08-14 at 15:47 +0200, Martin Schwidefsky wrote:
> > plain text document attachment (clocksource-select.diff)
> > From: Martin Schwidefsky <schwidefsky@de.ibm.com>
> > 
> > If a non high-resolution clocksource is first set as override clock
> > and then registered it becomes active even if the system is in
> > on-shot mode. Move the override check from sysfs_override_clocksource
> > to the clocksource selection. That fixes the bug and simplifies the
> > code. The check in clocksource_register for double registration of
> > the same clocksource is removed without replacement.
> > 
> > To find the initial clocksource a new weak function in jiffies.c is
> > defined that returns the jiffies clocksource. The architecture code
> > can then override the weak function with a more suitable clocksource,
> > e.g. the TOD clock on s390.
> 
> 
> Hey Martin, 
> 
> So I found the issue I sent mail about earlier, this is patch breaks
> sysfs clocksource overrides. The suggested fix is below:
> 
> 
> > @@ -478,10 +478,6 @@ static ssize_t sysfs_override_clocksourc
> >  					  struct sysdev_attribute *attr,
> >  					  const char *buf, size_t count)
> >  {
> > -	struct clocksource *ovr = NULL;
> > -	size_t ret = count;
> > -	int len;
> > -
> >  	/* strings from sysfs write are not 0 terminated! */
> >  	if (count >= sizeof(override_name))
> >  		return -EINVAL;
> > @@ -495,41 +491,11 @@ static ssize_t sysfs_override_clocksourc
> >  	if (count > 0)
> >  		memcpy(override_name, buf, count);
> >  	override_name[count] = 0;
> > -
> > -	len = strlen(override_name);
> > -	if (len) {
> > -		struct clocksource *cs;
> > -
> > -		ovr = clocksource_override;
> > -		/* try to select it: */
> > -		list_for_each_entry(cs, &clocksource_list, list) {
> > -			if (strlen(cs->name) == len &&
> > -			    !strcmp(cs->name, override_name))
> > -				ovr = cs;
> > -		}
> > -	}
> > -
> > -	/*
> > -	 * Check to make sure we don't switch to a non-highres capable
> > -	 * clocksource if the tick code is in oneshot mode (highres or nohz)
> > -	 */
> > -	if (tick_oneshot_mode_active() && ovr &&
> > -	    !(ovr->flags & CLOCK_SOURCE_VALID_FOR_HRES)) {
> > -		printk(KERN_WARNING "%s clocksource is not HRT compatible. "
> > -			"Cannot switch while in HRT/NOHZ mode\n", ovr->name);
> > -		ovr = NULL;
> > -		override_name[0] = 0;
> > -	}
> > -
> > -	/* Reselect, when the override name has changed */
> > -	if (ovr != clocksource_override) {
> > -		clocksource_override = ovr;
> > -		next_clocksource = select_clocksource();
> > -	}
> > +	clocksource_select();
> > 
> >  	spin_unlock_irq(&clocksource_lock);
> > 
> > -	return ret;
> > +	return count;
> >  }
> 
> Here when you return count, count may have been decremented in the code
> above, which causes the writer to get back fewer bytes then what they
> passed in, causing the last char to be repeatedly sent. This is what
> causes the immediate switch back to the default clocksource (override
> gets set to null), and the hang of the command writing to the sysfs
> file.
> 
> The fix is simply keeping the initial "size_t ret = count;" and the
> final "return ret;"
> 

Oh, and with this small fixup the entire stack seems to be working
properly.

thanks
-john


  reply	other threads:[~2009-08-15  1:44 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 13:47 [patch 00/15] clocksource / timekeeping rework V4 (resend V3 + bug fix) Martin Schwidefsky
2009-08-14 13:47 ` [patch 01/15] introduce timekeeping_leap_insert Martin Schwidefsky
2009-08-15  9:01   ` [tip:timers/core] timekeeping: Introduce timekeeping_leap_insert tip-bot for John Stultz
2009-08-14 13:47 ` [patch 02/15] remove clocksource inline functions Martin Schwidefsky
2009-08-15  9:01   ` [tip:timers/core] timekeeping: Remove " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 03/15] reset of cycle_last for tsc clocksource Martin Schwidefsky
2009-08-15  9:01   ` [tip:timers/core] timekeeping: Move reset of cycle_last for tsc clocksource to tsc tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 04/15] cleanup clocksource selection Martin Schwidefsky
2009-08-15  1:42   ` john stultz
2009-08-15  1:43     ` john stultz [this message]
2009-08-17  7:34     ` Martin Schwidefsky
2009-08-15  9:02   ` [tip:timers/core] clocksource: Cleanup " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 05/15] clocksource watchdog highres enablement Martin Schwidefsky
2009-08-15  9:02   ` [tip:timers/core] clocksource: Delay " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 06/15] clocksource watchdog resume logic Martin Schwidefsky
2009-08-15  9:02   ` [tip:timers/core] clocksource: Simplify " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 07/15] clocksource watchdog refactoring Martin Schwidefsky
2009-08-15  9:02   ` [tip:timers/core] clocksource: Refactor clocksource watchdog tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 08/15] clocksource watchdog work Martin Schwidefsky
2009-08-15  9:03   ` [tip:timers/core] clocksource: Move watchdog downgrade to a work queue thread tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 09/15] introduce struct timekeeper Martin Schwidefsky
2009-08-15  9:03   ` [tip:timers/core] timekeeping: Introduce " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 10/15] add xtime_shift and ntp_error_shift to " Martin Schwidefsky
2009-08-15  9:03   ` [tip:timers/core] timekeeping: Add " tip-bot for Martin Schwidefsky
2009-08-15  9:04   ` [patch 10/15] add " Thomas Gleixner
2009-08-14 13:47 ` [patch 11/15] move NTP adjusted clock multiplier " Martin Schwidefsky
2009-08-15  9:03   ` [tip:timers/core] timekeeping: Move " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 12/15] timekeeper read clock helper functions Martin Schwidefsky
2009-08-15  9:03   ` [tip:timers/core] timekeeping: Add timekeeper read_clock " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 13/15] update clocksource with stop_machine Martin Schwidefsky
2009-08-15  9:04   ` [tip:timers/core] timekeeping: Update " tip-bot for Martin Schwidefsky
2009-08-14 13:47 ` [patch 14/15] read_persistent_clock should return a timespec Martin Schwidefsky
2009-08-15  9:04   ` [tip:timers/core] timekeeping: Increase granularity of read_persistent_clock() tip-bot for Martin Schwidefsky
2009-08-22 10:32     ` Ingo Molnar
2009-08-22 15:15       ` Martin Schwidefsky
2009-08-22 15:33         ` Ingo Molnar
2009-08-22 20:23           ` Martin Schwidefsky
2009-08-23  8:53             ` Ingo Molnar
2009-08-23  9:03             ` [tip:timers/core] timekeeping: Increase granularity of read_persistent_clock(), build fix tip-bot for Martin Schwidefsky
2009-08-23  3:33           ` [tip:timers/core] timekeeping: Increase granularity of read_persistent_clock() Paul Mackerras
2009-08-23  8:47             ` Ingo Molnar
2009-08-24  3:20               ` Paul Mackerras
2009-08-24  8:23                 ` Ingo Molnar
2009-08-25  3:49                   ` Paul Mackerras
2009-08-25  8:26                     ` Ingo Molnar
2009-08-25  9:57                       ` Paul Mackerras
2009-08-25 10:17                         ` Ingo Molnar
2009-08-25 11:33                           ` Paul Mackerras
2009-08-25 13:50                             ` Ingo Molnar
2009-08-25 21:33                               ` Theodore Tso
2009-08-25 22:03                                 ` Ingo Molnar
2009-08-26  0:26                                   ` Paul Mackerras
2009-08-26  0:22                                 ` Paul Mackerras
2009-08-25 23:48                               ` Paul Mackerras
2009-08-26  9:44                               ` Benjamin Herrenschmidt
2009-08-14 13:47 ` [patch 15/15] introduce read_boot_clock Martin Schwidefsky
2009-08-15  9:04   ` [tip:timers/core] timekeeping: Introduce read_boot_clock tip-bot for Martin Schwidefsky
2009-08-14 14:08 ` [patch 00/15] clocksource / timekeeping rework V4 (resend V3 + bug fix) Thomas Gleixner
2009-08-14 14:22   ` Martin Schwidefsky
2009-08-14 22:56 ` john stultz
2009-08-15  1:46 ` john stultz
2009-08-15  9:01   ` Thomas Gleixner
2009-08-15  9:52     ` Ingo Molnar
2009-08-15 10:08       ` Thomas Gleixner
2009-08-17  7:40         ` Martin Schwidefsky
2009-08-17  8:45           ` Thomas Gleixner
2009-08-17  9:28             ` [circular locking bug] " Ingo Molnar
2009-08-17 17:53               ` Martin Schwidefsky
2009-08-18 15:09               ` Martin Schwidefsky
2009-08-19 10:06                 ` [tip:timers/core] clocksource: Avoid clocksource watchdog circular locking dependency tip-bot for Martin Schwidefsky
2009-08-19 20:25                 ` [circular locking bug] Re: [patch 00/15] clocksource / timekeeping rework V4 (resend V3 + bug fix) Ingo Molnar
2009-08-20  9:28                   ` Martin Schwidefsky
2009-08-20  9:58                     ` Ingo Molnar
2009-08-20 10:35                       ` Martin Schwidefsky
2009-08-20 16:14                         ` Thomas Gleixner
2009-08-20 16:53                           ` Martin Schwidefsky
2009-08-20 19:08                             ` Thomas Gleixner
2009-08-19  9:46             ` [tip:timers/core] clocksource: Protect the watchdog rating changes with clocksource_mutex tip-bot for Thomas Gleixner

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=1250300592.8269.27.camel@localhost.localdomain \
    --to=johnstul@us.ibm.com \
    --cc=dwalker@fifo99.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=schwidefsky@de.ibm.com \
    --cc=tglx@linutronix.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox