/******************************************************************************
 *
 *   Copyright © International Business Machines  Corp., 2009
 *
 *   This program is free software;  you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation; either version 2 of the License, or
 *   (at your option) any later version.
 *
 * DESCRIPTION
 *      Test if FUTEX_WAIT op returns -EWOULDBLOCK if the futex value differs
 *      from the expected one.
 *
 * AUTHOR
 *      Gowrishankar <gowrishankar.m@in.ibm.com>
 *
 * HISTORY
 *      2009-Nov-14: Initial version by Gowrishankar <gowrishankar.m@in.ibm.com>
 *
 *****************************************************************************/

#include <errno.h>
#include <getopt.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "futextest.h"
#include "logging.h"

#define timeout_ns 100000

void usage(char *prog)
{
	printf("Usage: %s\n", prog);
	printf("  -c	Use color\n");
	printf("  -h	Display this help message\n");
	printf("  -v L	Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
	       VQUIET, VCRITICAL, VINFO);
}

int main(int argc, char *argv[])
{
	struct timespec to = {.tv_sec = 0, .tv_nsec = timeout_ns};
	futex_t f1 = FUTEX_INITIALIZER;
	int res, ret = RET_PASS;
	int c;

	while ((c = getopt(argc, argv, "cht:v:")) != -1) {
		switch (c) {
		case 'c':
			log_color(1);
			break;
		case 'h':
			usage(basename(argv[0]));
			exit(0);
		case 'v':
			log_verbosity(atoi(optarg));
			break;
		default:
			usage(basename(argv[0]));
			exit(1);
		}
	}

	printf("%s: Test the unexpected futex value in FUTEX_WAIT\n",
	       basename(argv[0]));

	info("Calling futex_wait on f1: %u @ %p with val=%u\n", f1, &f1, f1+1);
	res = futex_wait(&f1, f1+1, &to, FUTEX_PRIVATE_FLAG);
	if (!res || errno != EWOULDBLOCK) {
		fail("futex_wait returned: %d %s\n",
		     res ? errno : res, res ? strerror(errno) : "");
		ret = RET_FAIL;
	}

	print_result(ret);
	return ret;
}
</td><td class='form'><form class='right' method='get' action='/cgit.cgi/linux/net-next.git/log/include/net/netns/hash.h'>
<input type='hidden' name='id' value='fc52497eb9dd031de9d17af54ac8f4078663a9f5'/><select name='qt'>
<option value='grep'>log msg</option>
<option value='author'>author</option>
<option value='committer'>committer</option>
<option value='range'>range</option>
</select>
<input class='txt' type='search' size='10' name='q' value=''/>
<input type='submit' value='search'/>
</form>
</td></tr></table>
<div class='path'>path: <a href='/cgit.cgi/linux/net-next.git/log/?id=fc52497eb9dd031de9d17af54ac8f4078663a9f5'>root</a>/<a href='/cgit.cgi/linux/net-next.git/log/include?id=fc52497eb9dd031de9d17af54ac8f4078663a9f5'>include</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net?id=fc52497eb9dd031de9d17af54ac8f4078663a9f5'>net</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net/netns?id=fc52497eb9dd031de9d17af54ac8f4078663a9f5'>netns</a>/<a href='/cgit.cgi/linux/net-next.git/log/include/net/netns/hash.h?id=fc52497eb9dd031de9d17af54ac8f4078663a9f5'>hash.h</a></div><div class='content'><table class='list nowrap'><tr class='nohover'><th class='left'>Age</th><th class='left'>Commit message (<a href='/cgit.cgi/linux/net-next.git/log/include/net/netns/hash.h?id=fc52497eb9dd031de9d17af54ac8f4078663a9f5&amp;showmsg=1'>Expand</a>)</th><th class='left'>Author</th><th class='left'>Files</th><th class='left'>Lines</th></tr>
<form method='get'><input type='hidden' name='h' value='nds-private-remove'/><input type='hidden' name='id' value='dd86e373e09fb16b83e8adf5c48c421a4ca76468'/><table><tr><td colspan='2'/></tr><tr><td class='label'>context:</td><td class='ctrl'><select name='context' onchange='this.form.submit();'><option value='1'>1</option><option value='2'>2</option><option value='3' selected='selected'>3</option><option value='4'>4</option><option value='5'>5</option><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'>
<tr><th>author</th><td>Thomas Gleixner &lt;tglx@linutronix.de&gt;</td><td class='right'>2017-01-31 23:58:38 +0100</td></tr>
<tr><th>committer</th><td>Ingo Molnar &lt;mingo@kernel.org&gt;</td><td class='right'>2017-02-01 08:37:27 +0100</td></tr>
<tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/include/math-emu/quad.h?h=nds-private-remove&amp;id=dd86e373e09fb16b83e8adf5c48c421a4ca76468'>dd86e373e09fb16b83e8adf5c48c421a4ca76468</a> (<a href='/cgit.cgi/linux/net-next.git/patch/include/math-emu/quad.h?id=dd86e373e09fb16b83e8adf5c48c421a4ca76468'>patch</a>)</td></tr>
<tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?h=nds-private-remove&amp;id=dd86e373e09fb16b83e8adf5c48c421a4ca76468'>55703c2ea8584e303e342090614e0aab3509ab21</a> /<a href='/cgit.cgi/linux/net-next.git/tree/include/math-emu/quad.h?h=nds-private-remove&amp;id=dd86e373e09fb16b83e8adf5c48c421a4ca76468'>include/math-emu/quad.h</a></td></tr>
<tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/include/math-emu/quad.h?h=nds-private-remove&amp;id=0b3589be9b98994ce3d5aeca52445d1f5627c4ba'>0b3589be9b98994ce3d5aeca52445d1f5627c4ba</a> (<a href='/cgit.cgi/linux/net-next.git/diff/include/math-emu/quad.h?h=nds-private-remove&amp;id=dd86e373e09fb16b83e8adf5c48c421a4ca76468&amp;id2=0b3589be9b98994ce3d5aeca52445d1f5627c4ba'>diff</a>)</td></tr></table>
<div class='commit-subject'>perf/x86/intel/rapl: Make package handling more robust</div><div class='commit-msg'>The package management code in RAPL relies on package mapping being
available before a CPU is started. This changed with:

  9d85eb9119f4 ("x86/smpboot: Make logical package management more robust")

because the ACPI/BIOS information turned out to be unreliable, but that
left RAPL in broken state. This was not noticed because on a regular boot
all CPUs are online before RAPL is initialized.

A possible fix would be to reintroduce the mess which allocates a package
data structure in CPU prepare and when it turns out to already exist in
starting throw it away later in the CPU online callback. But that's a
horrible hack and not required at all because RAPL becomes functional for
perf only in the CPU online callback. That's correct because user space is
not yet informed about the CPU being onlined, so nothing caan rely on RAPL
being available on that particular CPU.

Move the allocation to the CPU online callback and simplify the hotplug
handling. At this point the package mapping is established and correct.

This also adds a missing check for available package data in the
event_init() function.

Reported-by: Yasuaki Ishimatsu &lt;yasu.isimatu@gmail.com&gt;
Signed-off-by: Thomas Gleixner &lt;tglx@linutronix.de&gt;
Cc: Alexander Shishkin &lt;alexander.shishkin@linux.intel.com&gt;
Cc: Arnaldo Carvalho de Melo &lt;acme@redhat.com&gt;
Cc: Jiri Olsa &lt;jolsa@redhat.com&gt;
Cc: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
Cc: Peter Zijlstra &lt;peterz@infradead.org&gt;
Cc: Sebastian Siewior &lt;bigeasy@linutronix.de&gt;
Cc: Stephane Eranian &lt;eranian@google.com&gt;
Cc: Vince Weaver &lt;vincent.weaver@maine.edu&gt;
Fixes: 9d85eb9119f4 ("x86/smpboot: Make logical package management more robust")
Link: http://lkml.kernel.org/r/20170131230141.212593966@linutronix.de
Signed-off-by: Ingo Molnar &lt;mingo@kernel.org&gt;
</div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?h=nds-private-remove&amp;id=dd86e373e09fb16b83e8adf5c48c421a4ca76468'>Diffstat</a> (limited to 'include/math-emu/quad.h')</div><table summary='diffstat' class='diffstat'>