From owner-svn-src-all@FreeBSD.ORG Wed Jul 27 06:24:24 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 01A04106564A; Wed, 27 Jul 2011 06:24:24 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id 609388FC0C; Wed, 27 Jul 2011 06:24:23 +0000 (UTC) Received: by yxl31 with SMTP id 31so650356yxl.13 for ; Tue, 26 Jul 2011 23:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=TvkPTOAL5xfuAtC1TfF/6/g4vxKkBNRHdUuW+yY0Q+k=; b=K6EfmJbn1jilcGIcSr8lVsfWD7m+mD/FcOi7iaaxDfER0kRq68opsw1I+nLZOle8ZT RoEVF27DukWLBqUxg2uZqbKZKW1PtIPxdho6sGlwgfs+UVp31iwCtZkSeTOL0x/0yF5S kWet7YSSDDsb6WerqxvKLDCW6cRMhHgVKHK7c= MIME-Version: 1.0 Received: by 10.150.179.18 with SMTP id b18mr6256843ybf.130.1311747862275; Tue, 26 Jul 2011 23:24:22 -0700 (PDT) Sender: pluknet@gmail.com Received: by 10.150.200.3 with HTTP; Tue, 26 Jul 2011 23:24:21 -0700 (PDT) In-Reply-To: <201107210920.09604.jhb@freebsd.org> References: <201107191300.p6JD0UU7073447@svn.freebsd.org> <201107210920.09604.jhb@freebsd.org> Date: Wed, 27 Jul 2011 10:24:21 +0400 X-Google-Sender-Auth: 361zTEAcNqPB-kFnZqFPux-2rVI Message-ID: From: Sergey Kandaurov To: John Baldwin Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, Attilio Rao , Robert Watson , Pan Tsu , svn-src-head@freebsd.org, Sean Bruno Subject: Re: svn commit: r224217 - in head/sys: amd64/include ia64/include mips/conf sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 27 Jul 2011 06:24:24 -0000 On 21 July 2011 17:20, John Baldwin wrote: > On Thursday, July 21, 2011 8:37:26 am Sergey Kandaurov wrote: >> On 21 July 2011 14:14, Attilio Rao wrote: >> > 2011/7/20 Pan Tsu : >> >> Attilio Rao writes: >> >> >> >>> Author: attilio >> >>> Date: Tue Jul 19 13:00:30 2011 >> >>> New Revision: 224217 >> >>> URL: http://svn.freebsd.org/changeset/base/224217 >> >>> >> >>> Log: >> >>> =A0 Bump MAXCPU for amd64, ia64 and XLP mips appropriately. >> >>> =A0 From now on, default values for FreeBSD will be 64 maxiumum supp= orted >> >>> =A0 CPUs on amd64 and ia64 and 128 for XLP. All the other architectu= res >> >>> =A0 seem already capped appropriately (with the exception of sparc64= which >> >>> =A0 needs further support on jalapeno flavour). >> >>> >> >>> =A0 Bump __FreeBSD_version in order to reflect KBI/KPI brekage intro= duced >> >>> =A0 during the infrastructure cleanup for supporting MAXCPU > 32. Th= is >> >>> =A0 covers cpumask_t retiral too. >> >>> >> >>> =A0 The switch is considered completed at the present time, so for > whatever >> >>> =A0 bug you may experience that is reconducible to that area, please > report >> >>> =A0 immediately. >> >>> >> >>> =A0 Requested by: =A0 =A0 =A0 marcel, jchandra >> >>> =A0 Tested by: =A0pluknet, sbruno >> >>> =A0 Approved by: =A0 =A0 =A0 =A0re (kib) >> >>> >> >>> Modified: >> >>> =A0 head/sys/amd64/include/param.h >> >>> =A0 head/sys/ia64/include/param.h >> >>> =A0 head/sys/mips/conf/XLP >> >>> =A0 head/sys/mips/conf/XLP64 >> >>> =A0 head/sys/mips/conf/XLPN32 >> >>> =A0 head/sys/sys/param.h >> >>> >> >>> Modified: head/sys/amd64/include/param.h >> >>> > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D >> >>> --- head/sys/amd64/include/param.h =A0 =A0Tue Jul 19 12:41:57 2011 > =A0(r224216) >> >>> +++ head/sys/amd64/include/param.h =A0 =A0Tue Jul 19 13:00:30 2011 > =A0(r224217) >> >>> @@ -65,7 +65,7 @@ >> >>> >> >>> =A0#if defined(SMP) || defined(KLD_MODULE) >> >>> =A0#ifndef MAXCPU >> >>> -#define MAXCPU =A0 =A0 =A0 =A0 =A0 =A0 =A0 32 >> >>> +#define MAXCPU =A0 =A0 =A0 =A0 =A0 =A0 =A0 64 >> >>> =A0#endif >> >>> =A0#else >> >>> =A0#define MAXCPU =A0 =A0 =A0 =A0 =A0 =A0 =A0 1 >> >> >> >> Do you plan to bump MEMSTAT_MAXCPU, too? >> >> >> >> =A0$ vmstat -z >> >> =A0vmstat: memstat_sysctl_uma: Too many CPUs >> >> =A0$ vmstat -m >> >> =A0vmstat: memstat_sysctl_malloc: Too many CPUs >> >> >> >> =A0$ sysctl kern. | grep smp.\*cpus >> >> =A0kern.smp.maxcpus: 64 >> >> =A0kern.smp.cpus: 2 >> >> >> > >> > Jeeeez, we seriously need to fix this getting rid of the static values= . >> > >> > Anyway, can you try the following patch?: >> > http://www.freebsd.org/~attilio/memstat_maxcpu.diff >> > >> > It is going to add some memory overhead for i386 case. >> > >> >> Something like this should work (vmstat -z, vmstat -m both work). >> It gets rid of MEMSTAT_MAXCPU at the expense of malloc() at runtime. >> http://plukky.net/~pluknet/patches/libmemstat_nomaxcpu.diff >> >> Probably it should work with maxid, instead of maxcpu to save some memor= y. >> Though, using maxcpu is more safe. > > Actually, I would prefer that it use mp_maxid as that is the general vari= able > things should use. =A0mp_maxcpus is a concession for the few places that = may > need to know the MAXCPUS value (e.g. if using libkvm to access a structur= e in > a crashdump or live kernel that has a member array with MAXCPU elements). > Code that just wants to allocate memory to hold per-CPU data should use > mp_maxid whenever possible. > Hi, I changed the patch to use mp_maxid wherever possible. http://plukky.net/~pluknet/patches/libmemstat_nomaxcpu.2.diff To summarize: 1) malloc stats kern.malloc_stats uses internally MAXCPU, and we have to query MAXCPU from kernel, too. See kern/kern_malloc.c:sysctl_kern_malloc_stats(): 849 mtsh.mtsh_maxcpus =3D MAXCPU; 1a) memstat_sysctl_malloc() left unchanged, sysctl kern.smp.maxcpus 1b) memstat_kvm_malloc() left unchanged, _mp_maxcpus symbol 2) uma stats vm.zone_stats uses (mp_maxid + 1), vm/uma_core.c:sysctl_vm_zone_stats(): 3247 ush.ush_maxcpus =3D (mp_maxid + 1); 2a) memstat_sysctl_uma() Switched to query sysctl kern.smp.maxid 2b) memstat_kvm_uma() left unchanged, _mp_maxid symbol So, there's only one change in memstat_sysctl_uma(). A bad side of things is that libmemstat() now knows these vm_zone and malloc_stats internals. As Robert suggested me on IRC to query maxcpu value from uma_stream_header and malloc_type_stream_header structures respectively to be independent from kernel details. --=20 wbr, pluknet