Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp70921ybh; Mon, 20 Jul 2020 10:34:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDehrgDiNPJQBavWMS6n0gEeBohODIbzusVoxFblQlnKHVAyq05HKTWmiHseIKtW7k6qli X-Received: by 2002:a17:906:5fc4:: with SMTP id k4mr21399572ejv.94.1595266482246; Mon, 20 Jul 2020 10:34:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595266482; cv=none; d=google.com; s=arc-20160816; b=YdQikDcgYyHWIfjurG9YFA+LLclPFWtUpkuuD1gZyV79LsHux6gRMo8mioHto8P1NG UzqKbYHdrrFbLlTI2F6cTU2h2sGLBXzBUoNlYEIyVfyMyr4jVZk16DRnc3oeFFp3t2Z1 hwaai+LCAoXmS+0byRBFL1U66CCi/hVUKlIBwMEjIoAtvo8GOyUcG7a0vCbbxSPf+PP8 Iq6i9jASg5dBqAFu3Ddj0SB52qY9sQwkk26duoWkm4E/6/bb1u50sejiVzrYSIxEs4D5 CHYHlwSBMmATqZiuETRk5RE4WS9uTH62XCxRBk1tfCmt+VozEL+IlyK/QIo+qrgj1bxi b9ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GlE22XiDFB+02pU5gzklDIha+BcKyqLDHWBhHRmLvCg=; b=RDsxW3B2UJmGwDm66w5vRS4QIE6Ojsakx03AU3PmQNkflFha4AkbVlJtpEc67KVcTr pVe4RIRR2ldWzLO9AQ3pKNd6w4+V7VC+2oyY41NKz9BssWzyCFLWHp24FqGOHlVyLpWQ BYoLYqePPMu00cVf2m71PZHpGpC+25+64tNazVY8K8UbIhuWJdYq5jlUU6+6udVszCac 5FYn25vUBlylbWMAEy3AibQVBBb8hH22RULBndr2FQcLoJzKNp0xeG5m6c+ZO3zCD5Jk wYLQoy1Coi+nYuMsV/3mIpzoR+SdBg6+P6C2j4PbuZAR2TN5ykxmNT74/aTNTcd+mNHC jE5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dfJBApBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s23si12948774edi.7.2020.07.20.10.34.18; Mon, 20 Jul 2020 10:34:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=dfJBApBk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732503AbgGTRdS (ORCPT + 99 others); Mon, 20 Jul 2020 13:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726812AbgGTRdR (ORCPT ); Mon, 20 Jul 2020 13:33:17 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FBC3C061794 for ; Mon, 20 Jul 2020 10:33:16 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id s9so1439444lfs.4 for ; Mon, 20 Jul 2020 10:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GlE22XiDFB+02pU5gzklDIha+BcKyqLDHWBhHRmLvCg=; b=dfJBApBkPqCxrfZaO8xj/Jd/hhxetMuW26nEQCNgDBr6vF++y2LiHqPaOr1n+OKIZu /U4IY9i+lR09yAOqpMqYvzuGB9ZkLFmuvo2qMhWI5MSqV4t9/Nxt497aI37ATZoJd+a6 S/L43y2Qe+I+2ZtGX2pcGaO0WBVoUdl/1eVmgkq7pmLyKMCLqMhNL8D//TjqyKbvftDg lR+S1reD0MPs2fPw8jgCcPJetsFjmnESHyo+DoDljyDpFRJfDvzxdY+VkAXQShrkOGNX 920eCIyJyJmNm/LSDuRjDQ/LxF3Z2m6hKy63hranT86ULSBf1F/hsGgXAjY8G/Td+jwF a62Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=GlE22XiDFB+02pU5gzklDIha+BcKyqLDHWBhHRmLvCg=; b=R9PuIc3yxIw2/JvRhEP2QPoVCSlSranL4+evCTs7TGIcuhLvhvOmJfVFTM7BC7e48K R7jE/CcV0vgxuCx2fxI/xwg4MrO/v9G3RjjztnS3MXlgFCbvlrR5g6sQ++kRkvFt/HI2 ul3RGTUxQTKJCakToUCb6QaaGa1XncNtF7dHybca1wFbWxa19uewhUUa6WKWExibJlkF hAFyWUmsyxB0vGKniRJcgvH+ZodrYeKGUpdpzhfAIVtAJY4St+DnLrcEUXDJMKgW5g4I llcL05JuR5vVPxiB2CNdyoLERCjHjg8JzNS7pUjReI8o+5aU3+2d04Iu6cJ63cRHtFiw r5tQ== X-Gm-Message-State: AOAM532UdyK+s3OeRPll99BhJufCVOSCrAL7X8vxHUYRO8+EDIIgaFXV TUkIrjedkC6Wsb8t9z75S0c= X-Received: by 2002:a05:6512:31d5:: with SMTP id j21mr11355350lfe.83.1595266395106; Mon, 20 Jul 2020 10:33:15 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id b9sm976048lfi.88.2020.07.20.10.33.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jul 2020 10:33:13 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id 5CE871A007A; Mon, 20 Jul 2020 20:33:13 +0300 (MSK) Date: Mon, 20 Jul 2020 20:33:13 +0300 From: Cyrill Gorcunov To: kan.liang@linux.intel.com Cc: peterz@infradead.org, mingo@redhat.com, acme@kernel.org, tglx@linutronix.de, bp@alien8.de, x86@kernel.org, linux-kernel@vger.kernel.org, dave.hansen@intel.com, yu-cheng.yu@intel.com, bigeasy@linutronix.de, hpa@zytor.com, eranian@google.com, ak@linux.intel.com, chang.seok.bae@intel.com Subject: Re: [PATCH] x86/fpu/xstate: Fix an xstate size check warning Message-ID: <20200720173313.GA4221@grain> References: <1595253051-75374-1-git-send-email-kan.liang@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1595253051-75374-1-git-send-email-kan.liang@linux.intel.com> User-Agent: Mutt/1.14.5 (2020-06-23) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 20, 2020 at 06:50:51AM -0700, kan.liang@linux.intel.com wrote: ... > static unsigned int __init get_xsave_size(void) > { > unsigned int eax, ebx, ecx, edx; > @@ -710,7 +741,7 @@ static int __init init_xstate_size(void) > xsave_size = get_xsave_size(); > > if (boot_cpu_has(X86_FEATURE_XSAVES)) > - possible_xstate_size = get_xsaves_size(); > + possible_xstate_size = get_xsaves_size_no_dynamic(); > else > possible_xstate_size = xsave_size; Hi! Maybe we could enhance get_xsaves_size instead ? The get_xsaves_size is static and __init function (thus not a hot path) used once as far as I see. Say static unsigned int __init get_xsaves_size(void) { u64 mask = xfeatures_mask_dynamic(); unsigned int eax, ebx, ecx, edx; /* * In case if dynamic features are present make * sure they are not accounted in the result since * the buffer should be allocated separately from * task->fpu. */ if (mask) wrmsrl(MSR_IA32_XSS, xfeatures_mask_supervisor()); /* * - CPUID function 0DH, sub-function 1: * EBX enumerates the size (in bytes) required by * the XSAVES instruction for an XSAVE area * containing all the state components * corresponding to bits currently set in * XCR0 | IA32_XSS. */ cpuid_count(XSTATE_CPUID, 1, &eax, &ebx, &ecx, &edx); if (mask) wrmsrl(MSR_IA32_XSS, xfeatures_mask_supervisor() | mask); return ebx; } but if you expect more use of get_xsaves_size_no_dynamic() and get_xsaves_size() in future then sure, we need a separate function. The benefit from such extension is that when you read get_xsaves_size you'll notice the dependency on dynamic features immediaely. Though I'm fine with current patch as well, up to you. Thanks for the patch! Reviewed-by: Cyrill Gorcunov