Skip to contentSkip to conversation

sched_getaffinity fails with EINVAL in 2.6.31-rc4

regression Gregory Haskins 4 participants 6 messages Jul 27, 2009 – Jul 29, 2009

lore
Share & tools
lore
#0 lore raw

I am not sure when this started, but noticed that sched_getaffinity is not working in -rc4.

[pid 6254] sched_getaffinity(0, 128, 0x7f80586b1fe0) = -1 EINVAL (Invalid argument)

Here is a simple program for reproduction:

#include <sched.h>

int main(void)

{
	cpu_set_t mask;
	int ret;

	ret = sched_getaffinity(0, sizeof(mask), &mask);
	if (ret < 0)
		perror("getaffinity");

	return ret;
}

If I get time, I will bisect this later today.

Regards,
-Greg

#1 lore raw
Quoted 7 lines · Gregory Haskins

I am not sure when this started, but noticed that sched_getaffinity is not working in -rc4.

[pid 6254] sched_getaffinity(0, 128, 0x7f80586b1fe0) = -1 EINVAL (Invalid argument)

Here is a simple program for reproduction:

Thanks,

I have a box available in which I can look at this further.

-- Steve

Quoted 21 lines

#include <sched.h>

int main(void)

{
	cpu_set_t mask;
	int ret;

	ret = sched_getaffinity(0, sizeof(mask), &mask);
	if (ret < 0)
		perror("getaffinity");

	return ret;
}

If I get time, I will bisect this later today.

Regards,
-Greg

#2 lore raw
In reply to Gregory Haskins
Quoted 22 lines · Gregory Haskins

I am not sure when this started, but noticed that sched_getaffinity is not working in -rc4.

[pid 6254] sched_getaffinity(0, 128, 0x7f80586b1fe0) = -1 EINVAL (Invalid argument)

Here is a simple program for reproduction:

#include <sched.h>

int main(void)

{
	cpu_set_t mask;
	int ret;

	ret = sched_getaffinity(0, sizeof(mask), &mask);
	if (ret < 0)
		perror("getaffinity");

	return ret;
}
Quoted 2 lines

If I get time, I will bisect this later today.

It's most likely due to the cpumask changes. I don't know what cpu_set_t is, but it's probably smaller than CONFIG_NR_CPUS rounded up to a multiple of sizeof(long).

#3 lore raw
Quoted 24 lines · David Rientjes
Quoted 22 lines · Gregory Haskins

I am not sure when this started, but noticed that sched_getaffinity is not working in -rc4.

[pid 6254] sched_getaffinity(0, 128, 0x7f80586b1fe0) = -1 EINVAL (Invalid argument)

Here is a simple program for reproduction:

#include <sched.h>

int main(void)

{
	cpu_set_t mask;
	int ret;

	ret = sched_getaffinity(0, sizeof(mask), &mask);
	if (ret < 0)
		perror("getaffinity");

	return ret;
}
Quoted 6 lines
Quoted 2 lines

If I get time, I will bisect this later today.

It's most likely due to the cpumask changes. I don't know what cpu_set_t is, but it's probably smaller than CONFIG_NR_CPUS rounded up to a multiple of sizeof(long).

It's simply that you finally ran this on a kernel which had CONFIG_NR_CPUS > 1024.

I argued strongly against the set and getaffinity interfaces when they were introduced; they can't be used in general without a loop (enlarge cpu_set, retry).

Cheers,
Rusty.

#4 lore raw
Quoted 4 lines · Rusty Russell

I argued strongly against the set and getaffinity interfaces when they were introduced; they can't be used in general without a loop (enlarge cpu_set, retry).

Right, so the functional regression here is glibc 2.3.2 -> 2.3.3.

#5 lore raw
In reply to Rusty Russell
Quoted 25 lines · Rusty Russell
Quoted 24 lines · David Rientjes
Quoted 22 lines · Gregory Haskins

I am not sure when this started, but noticed that sched_getaffinity is not working in -rc4.

[pid 6254] sched_getaffinity(0, 128, 0x7f80586b1fe0) = -1 EINVAL (Invalid argument)

Here is a simple program for reproduction:

#include <sched.h>

int main(void)

{
	cpu_set_t mask;
	int ret;

	ret = sched_getaffinity(0, sizeof(mask), &mask);
	if (ret < 0)
		perror("getaffinity");

	return ret;
}
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

If I get time, I will bisect this later today.

It's most likely due to the cpumask changes. I don't know what cpu_set_t is, but it's probably smaller than CONFIG_NR_CPUS rounded up to a multiple of sizeof(long).

It's simply that you finally ran this on a kernel which had CONFIG_NR_CPUS > 1024.

Indeed. I thought I had replied to the list that I figured that out, but I think it might have been a trimmed list from someone elses reply.

Long story short, MAXSMP=y crept in, which set NR_CPUS=4096. Backing this off < 1024 indeed fixes the issue.

Thanks to all who replied!
-Greg