From owner-svn-src-head@freebsd.org Sat May 6 17:37:03 2017 Return-Path: Delivered-To: svn-src-head@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 53221D61D2D; Sat, 6 May 2017 17:37:03 +0000 (UTC) (envelope-from mmokhi@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A40231A34; Sat, 6 May 2017 17:37:02 +0000 (UTC) (envelope-from mmokhi@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v46Hb12l067179; Sat, 6 May 2017 17:37:01 GMT (envelope-from mmokhi@FreeBSD.org) Received: (from mmokhi@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v46Hb1Aq067178; Sat, 6 May 2017 17:37:01 GMT (envelope-from mmokhi@FreeBSD.org) Message-Id: <201705061737.v46Hb1Aq067178@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmokhi set sender to mmokhi@FreeBSD.org using -f From: Mahdi Mokhtari Date: Sat, 6 May 2017 17:37:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r317884 - head/sys/compat/linprocfs X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 06 May 2017 17:37:03 -0000 Author: mmokhi (ports committer) Date: Sat May 6 17:37:01 2017 New Revision: 317884 URL: https://svnweb.freebsd.org/changeset/base/317884 Log: Fix linprocfs_docpuinfo() output regarding to what newer Linux apps expect Reviewed by: trasz Approved by: trasz MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D10274 Modified: head/sys/compat/linprocfs/linprocfs.c Modified: head/sys/compat/linprocfs/linprocfs.c ============================================================================== --- head/sys/compat/linprocfs/linprocfs.c Sat May 6 16:06:33 2017 (r317883) +++ head/sys/compat/linprocfs/linprocfs.c Sat May 6 17:37:01 2017 (r317884) @@ -202,8 +202,9 @@ linprocfs_docpuinfo(PFS_FILL_ARGS) char model[128]; uint64_t freq; size_t size; + u_int cache_size[4]; int fqmhz, fqkhz; - int i; + int i, j; /* * We default the flags to include all non-conflicting flags, @@ -219,27 +220,20 @@ linprocfs_docpuinfo(PFS_FILL_ARGS) "3dnowext", "3dnow" }; + static char *power_flags[] = { + "ts", "fid", "vid", + "ttp", "tm", "stc", + "100mhzsteps", "hwpstate", "", + "cpb", "eff_freq_ro", "proc_feedback", + "acc_power", + }; + hw_model[0] = CTL_HW; hw_model[1] = HW_MODEL; model[0] = '\0'; size = sizeof(model); if (kernel_sysctl(td, hw_model, 2, &model, &size, 0, 0, 0, 0) != 0) strcpy(model, "unknown"); - for (i = 0; i < mp_ncpus; ++i) { - sbuf_printf(sb, - "processor\t: %d\n" - "vendor_id\t: %.20s\n" - "cpu family\t: %u\n" - "model\t\t: %u\n" - "model name\t: %s\n" - "stepping\t: %u\n\n", - i, cpu_vendor, CPUID_TO_FAMILY(cpu_id), - CPUID_TO_MODEL(cpu_id), model, cpu_id & CPUID_STEPPING); - /* XXX per-cpu vendor / class / model / id? */ - } - - sbuf_cat(sb, "flags\t\t:"); - #ifdef __i386__ switch (cpu_vendor_id) { case CPU_VENDOR_AMD: @@ -251,20 +245,70 @@ linprocfs_docpuinfo(PFS_FILL_ARGS) break; } #endif - - for (i = 0; i < 32; i++) - if (cpu_feature & (1 << i)) - sbuf_printf(sb, " %s", flags[i]); - sbuf_cat(sb, "\n"); - freq = atomic_load_acq_64(&tsc_freq); - if (freq != 0) { - fqmhz = (freq + 4999) / 1000000; - fqkhz = ((freq + 4999) / 10000) % 100; + do_cpuid(0x80000006, cache_size); + for (i = 0; i < mp_ncpus; ++i) { + fqmhz = 0; + fqkhz = 0; + freq = atomic_load_acq_64(&tsc_freq); + if (freq != 0) { + fqmhz = (freq + 4999) / 1000000; + fqkhz = ((freq + 4999) / 10000) % 100; + } sbuf_printf(sb, + "processor\t: %d\n" + "vendor_id\t: %.20s\n" + "cpu family\t: %u\n" + "model\t\t: %u\n" + "model name\t: %s\n" + "stepping\t: %u\n" "cpu MHz\t\t: %d.%02d\n" - "bogomips\t: %d.%02d\n", - fqmhz, fqkhz, fqmhz, fqkhz); + "cache size\t: %d KB\n" + "physical id\t: %d\n" + "siblings\t: %d\n" + "core id\t\t: %d\n" + "cpu cores\t: %d\n" + "apicid\t\t: %d\n" + "initial apicid\t: %d\n" + "fpu\t\t: %s\n" + "fpu_exception\t: %s\n" + "cpuid level\t: %d\n" + "wp\t\t: %s\n", + i, cpu_vendor, CPUID_TO_FAMILY(cpu_id), + CPUID_TO_MODEL(cpu_id), model, cpu_id & CPUID_STEPPING, + fqmhz, fqkhz, + (cache_size[2] >> 16), 0, mp_ncpus, i, mp_ncpus, + i, i, /*cpu_id & CPUID_LOCAL_APIC_ID ??*/ + (cpu_feature & CPUID_FPU) ? "yes" : "no", "yes", + CPUID_TO_FAMILY(cpu_id), "yes"); + sbuf_cat(sb, "flags\t\t:"); + for (j = 0; j < nitems(flags); j++) + if (cpu_feature & (1 << j)) + sbuf_printf(sb, " %s", flags[j]); + sbuf_cat(sb, "\n"); + sbuf_printf(sb, + "bugs\t\t: %s\n" + "bogomips\t: %d.%02d\n" + "clflush size\t: %d\n" + "cache_alignment\t: %d\n" + "address sizes\t: %d bits physical, %d bits virtual\n", +#if defined(I586_CPU) && !defined(NO_F00F_HACK) + (has_f00f_bug) ? "Intel F00F" : "", +#else + "", +#endif + fqmhz, fqkhz, + cpu_clflush_line_size, cpu_clflush_line_size, + cpu_maxphyaddr, + (cpu_maxphyaddr > 32) ? 48 : 0); + sbuf_cat(sb, "power management: "); + for (j = 0; j < nitems(power_flags); j++) + if (amd_pminfo & (1 << j)) + sbuf_printf(sb, " %s", power_flags[j]); + sbuf_cat(sb, "\n\n"); + + /* XXX per-cpu vendor / class / model / id? */ } + sbuf_cat(sb, "\n"); return (0); }