From owner-p4-projects@FreeBSD.ORG Thu Aug 2 19:21:09 2007 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id C161416A420; Thu, 2 Aug 2007 19:21:09 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92D9516A417; Thu, 2 Aug 2007 19:21:09 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from vlakno.cz (vlk.vlakno.cz [62.168.28.247]) by mx1.freebsd.org (Postfix) with ESMTP id 07B0A13C47E; Thu, 2 Aug 2007 19:21:08 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from localhost (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 8C7F88C09CD; Thu, 2 Aug 2007 21:21:06 +0200 (CEST) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by localhost (vlk.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id U-JgpZVvHKte; Thu, 2 Aug 2007 21:21:05 +0200 (CEST) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 3354E8C09CC; Thu, 2 Aug 2007 21:21:05 +0200 (CEST) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.13.8/8.13.8/Submit) id l72JL48Y049369; Thu, 2 Aug 2007 21:21:04 +0200 (CEST) (envelope-from rdivacky) Date: Thu, 2 Aug 2007 21:21:04 +0200 From: Roman Divacky To: Jung-uk Kim Message-ID: <20070802192104.GA49318@freebsd.org> References: <200708021130.l72BUHrY077198@repoman.freebsd.org> <200708021356.58217.jkim@FreeBSD.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200708021356.58217.jkim@FreeBSD.org> User-Agent: Mutt/1.4.2.3i Cc: perforce@FreeBSD.org Subject: Re: PERFORCE change 124529 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Aug 2007 19:21:10 -0000 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?