From owner-freebsd-arch@freebsd.org Wed Nov 15 13:35:09 2017 Return-Path: Delivered-To: freebsd-arch@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 541BBDDD1B3 for ; Wed, 15 Nov 2017 13:35:09 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "vps1.elischer.org", Issuer "CA Cert Signing Authority" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 26C4B6B59D; Wed, 15 Nov 2017 13:35:08 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from Julian-MBP3.local (124-148-77-206.dyn.iinet.net.au [124.148.77.206]) (authenticated bits=0) by vps1.elischer.org (8.15.2/8.15.2) with ESMTPSA id vAFDYwtB090808 (version=TLSv1.2 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 15 Nov 2017 05:35:03 -0800 (PST) (envelope-from julian@freebsd.org) Subject: Re: small patch for numactl. Comments? To: Larry McVoy , Conrad Meyer Cc: scottl@netflix.com, kbowling@llnw.com, gallatin@netflix.com, "freebsd-arch@freebsd.org" References: <20171114020138.GA18863@mcvoy.com> <20171114140654.GC21209@mcvoy.com> From: Julian Elischer Message-ID: Date: Wed, 15 Nov 2017 21:34:53 +0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171114140654.GC21209@mcvoy.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Nov 2017 13:35:09 -0000 On 14/11/17 10:06 pm, Larry McVoy wrote: > Hi Conrad, > > Nice idea but pretty awkward compared to checking an env var. > I'd have to #ifdef up the code for numa (the benchmark in question > is portable to all the active Unix based systems and a lot of dead > ones). > > Is it not a thing on FreeBSD to use the environment to pass state > like this? it's not unheard of, but it's not common. I can't think of other examples off the top of my head except for sshd, sudo and other login type things. there is no reason NOT to other than the fact that you are the only user of the feature.. You could make it more useful by putting information more useful than "YES" there.. It also is only useful if you use numactl to do the work. Any other methods of setting Numa related settings would not have it. ..  Also environments get cleared in many situations. It's  workable solution for you. I'd go with it for now.. > > --lm > > On Mon, Nov 13, 2017 at 08:28:57PM -0800, Conrad Meyer wrote: >> Hi Larry, >> >> What if instead, the benchmark checked its own NUMA parameters? If a >> NUMA policy is not set, the benchmark can bail out with an >> admonishment. >> >> Best, >> Conrad >> >> >> On Mon, Nov 13, 2017 at 6:01 PM, Larry McVoy wrote: >>> Hi folks, some CDN people are dragging me out of retirement to work >>> on FreeBSD. Which I have to say is sort of fun since I started my >>> kernel hacking on SunOS 4.x which was a very very nice version of >>> BSD. But FreeBSD has mostly caught up, so it's pleasant. >>> >>> I'm wacking LMbench to be numa aware and this patch would help me make >>> sure that when you are a numa machine you could insist that people >>> run the benchmark via numactl (imma gonna blog about numa, it sucks >>> unless you are numa aware). >>> >>> I did some docs but I'm new to the FreeBSD man macros, would love >>> feedback on how to do that right. >>> >>> --- numactl.1 2017-11-13 17:51:26.243473000 -0800 >>> +++ numactl.1.lm 2017-11-13 17:51:20.494596000 -0800 >>> @@ -107,6 +107,15 @@ >>> .El >>> .Sh EXIT STATUS >>> .Ex -std >>> +.Sh ENVIRONMENT >>> +.Nm >>> +sets the environment variable >>> +\fINUMACTL=YES\fP >>> +before running >>> +.Ar cmd ... >>> +so that programs that know that they need to be run under >>> +.Nm >>> +can check. >>> .Sh EXAMPLES >>> Create a >>> .Pa /bin/sh >>> --- numactl.c 2017-11-13 16:18:36.134359000 -0800 >>> +++ numactl.c.lm 2017-11-13 16:18:28.530953000 -0800 >>> @@ -231,6 +231,7 @@ >>> (void) set_numa_domain_cpuaffinity(cpu_domain, >>> CPU_WHICH_PID, -1); >>> >>> + putenv("NUMACTL=YES"); >>> errno = 0; >>> execvp(*argv, argv); >>> err(errno == ENOENT ? 127 : 126, "%s", *argv); >>> _______________________________________________ >>> freebsd-arch@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-arch >>> To unsubscribe, send any mail to "freebsd-arch-unsubscribe@freebsd.org"