From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92DDFC54EBC for ; Thu, 12 Jan 2023 11:20:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232384AbjALLUl (ORCPT ); Thu, 12 Jan 2023 06:20:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238814AbjALLTt (ORCPT ); Thu, 12 Jan 2023 06:19:49 -0500 Received: from mail.skyhub.de (mail.skyhub.de [5.9.137.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF0C13DBDD; Thu, 12 Jan 2023 03:12:07 -0800 (PST) Received: from zn.tnic (p5de8e9fe.dip0.t-ipconnect.de [93.232.233.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 926031EC05F1; Thu, 12 Jan 2023 12:12:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1673521925; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=0vQOVZuKQjRWQ/e7isoLIfI6wGC5c5xNgWFk0olFibk=; b=p3NLvpJQL38wQx7laaSRDtG1IyQic4qNmIwn9kOtsfROkX701b3CXKkbs/R5FZTjuoprFS iTfWt7+i2spQAZ2yqVr7N3o52tPpqVl79crY84UzZUYQ6s31KIMeQns/7ea/LCEPoBpQkV yJ+FpQWMwUGgrzqcfkvOT0BfHJd6IXI= Date: Thu, 12 Jan 2023 12:12:02 +0100 From: Borislav Petkov To: Alexey Kardashevskiy Cc: kvm@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org, Venu Busireddy , Tony Luck , Tom Lendacky , Thomas Gleixner , Sean Christopherson , Sandipan Das , Peter Zijlstra , Pawan Gupta , Paolo Bonzini , Michael Roth , Mario Limonciello , Jan Kara , Ingo Molnar , Huang Rui , Dave Hansen , Daniel Sneddon , Brijesh Singh , Arnaldo Carvalho de Melo , Andrew Cooper , Alexander Shishkin , Adrian Hunter , "Jason A. Donenfeld" , "H. Peter Anvin" Subject: Re: [PATCH kernel v2 1/3] x86/amd: Cache values in percpu variables Message-ID: References: <20221209043804.942352-1-aik@amd.com> <20221209043804.942352-2-aik@amd.com> <61fde9ac-e24f-c765-a9a8-91fac60b9cb3@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <61fde9ac-e24f-c765-a9a8-91fac60b9cb3@amd.com> Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Thu, Jan 12, 2023 at 04:21:28PM +1100, Alexey Kardashevskiy wrote: > "that function" is set_dr_addr_mask() (btw should I rename it to start with > amd_? If you really wanna... I mean the code is already doing AMD-specific handling but sure, it'll be more obvious then that arch_install_hw_breakpoint() does only AMD-specific masking there under the info->mask test. > If it is out of bounds, it won't neither set or get. And these 2 helpers are > used only by the kernel and the callers pass 0..3 and nothing else. BUG_ON() > would do too, for example. Yeah, we don't do BUG_ON - look for Linus' colorful explanations why. :) In any case, I think we should always aim for proper recovery from errors but this case is not that important so let's leave it at the WARN_ON_ONCE. > imho having 1,2,3 in the code eliminates the need in a comment and produces > the exact same end result. But since nobody cares, I'll do it the shorter > way with just +1 and +2. Yeah, the more important goal is simplicity. And that pays off when you have to revisit that code and figure out what it does, later. > Sure. Out of curiosity - why?^w^w^w^w^ it reduced the vmlinux size by 48 > bytes, nice. The same answer - simplicity and speed when reading it. That if (per_cpu(amd_dr_addr_mask, smp_processor_id())[dr] == mask) is a bit harder to parse than if (per_cpu(amd_dr_addr_mask, cpu)[dr] == mask) Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette