Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 2 Aug 2007 21:21:04 +0200
From:      Roman Divacky <rdivacky@FreeBSD.org>
To:        Jung-uk Kim <jkim@FreeBSD.org>
Cc:        perforce@FreeBSD.org
Subject:   Re: PERFORCE change 124529 for review
Message-ID:  <20070802192104.GA49318@freebsd.org>
In-Reply-To: <200708021356.58217.jkim@FreeBSD.org>
References:  <200708021130.l72BUHrY077198@repoman.freebsd.org> <200708021356.58217.jkim@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 02, 2007 at 01:56:34PM -0400, Jung-uk Kim wrote:
> On Thursday 02 August 2007 07:30 am, Roman Divacky wrote:
> > +
> > +/* XXX: fake one.. waiting for ssouhlal to commit his patch */
> > +int
> > +linux_sched_getaffinity(struct thread *td, struct
> > linux_sched_getaffinity_args *args) +{
> > +	int error;
> > +	cpumask_t i = ~0;
> > +
> > +	if (args->len < sizeof(cpumask_t))
> > +		return (EINVAL);
> > +
> > +	error = copyout(&i, args->user_mask_ptr, sizeof(cpumask_t));
> > +	return (error);
> > +}
> 
> Er, shouldn't it be more like this?
> 
> int
> linux_sched_getaffinity(struct thread *td,
> 	struct linux_sched_getaffinity_args *args)
> {
> 	uint8_t	*mask;
> 	int	error;
> 
> 	if (args->cpusetsize < sizeof(cpumask_t))
> 		return (EINVAL);
> 
> 	mask = malloc(args->cpusetsize, M_LINUX, M_WAITOK);
> 	memset(mask, 0xff, args->cpusetsize);
> 	error = copyout(mask, args->mask, args->cpusetsize);
> 	free(mask, M_LINUX);
> 
> 	return (error);
> }
 
the linux 2.6.16 version does exactly what I implemented.

> The reason is because Linux can ask longer CPU mask than FreeBSD's.
> The (old) default used to be 1024-bit (128-byte) mask.  So, a lot
> of Linux apps still do that.

my version unbreaks java.. ie. I guess it cant be much wrong
 
> Also, can you match args to the Linux API?
> 
> int sched_getaffinity(pid_t pid, unsigned int cpusetsize, cpu_set_t *mask);
> 
> s/len/cpusetsize/
> s/user_mask_ptr/mask/

again.. 2.6.16 has exactly what I put there

where do you get the info about the linux version?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20070802192104.GA49318>