Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751453AbdFFRpK (ORCPT ); Tue, 6 Jun 2017 13:45:10 -0400 Received: from mail.skyhub.de ([5.9.137.197]:35146 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751390AbdFFRpJ (ORCPT ); Tue, 6 Jun 2017 13:45:09 -0400 Date: Tue, 6 Jun 2017 19:45:02 +0200 From: Borislav Petkov To: Peter Zijlstra Cc: Janakarajan Natarajan , linux-kernel@vger.kernel.org, Ingo Molnar , Arnaldo Carvalho de Melo , Alexander Shishkin , Suravee Suthikulpanit Subject: Re: [PATCH 2/2] amd: uncore: Get correct number of cores sharing last level cache Message-ID: <20170606174502.i4wc2xjge6lp4soy@pd.tnic> References: <42ddf980f25ffd0ba585f3cf3a7ca9ade4fc7bee.1496418338.git.Janakarajan.Natarajan@amd.com> <20170606101530.ehgizupxz4hy7ccv@hirez.programming.kicks-ass.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170606101530.ehgizupxz4hy7ccv@hirez.programming.kicks-ass.net> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 626 Lines: 26 On Tue, Jun 06, 2017 at 12:15:30PM +0200, Peter Zijlstra wrote: > Maybe something like: > > for (cache_level = 0; cache_level < 3; cache_level++) { > cpuid_count(0x8000001d, cache_level, &eax, &ebx, &ecx, &edx); > > if ((eax & 0x1f) == 0) /* EAX[0:4] gives cache type */ if (!(eax & 0x1f)) > break; > > prev_eax = eax; > } > > That way we'll not run off into the woods if CPUID goes funny (never > trust a BIOS/virt monkey). Yap, especially if there are CPUID functions with subleafs with holes in them. -- Regards/Gruss, Boris. Good mailing practices for 400: avoid top-posting and trim the reply.