From patchwork Thu May 23 09:41:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alejandro Vallejo X-Patchwork-Id: 13671545 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 lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 63B8AC25B79 for ; Thu, 23 May 2024 09:41:57 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.728280.1133143 (Exim 4.92) (envelope-from ) id 1sA4xD-0003pE-VP; Thu, 23 May 2024 09:41:43 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 728280.1133143; Thu, 23 May 2024 09:41:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA4xD-0003p7-Sk; Thu, 23 May 2024 09:41:43 +0000 Received: by outflank-mailman (input) for mailman id 728280; Thu, 23 May 2024 09:41:43 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sA4xD-0003m7-6G for xen-devel@lists.xenproject.org; Thu, 23 May 2024 09:41:43 +0000 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [2a00:1450:4864:20::432]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id a967d2d5-18e8-11ef-90a1-e314d9c70b13; Thu, 23 May 2024 11:41:42 +0200 (CEST) Received: by mail-wr1-x432.google.com with SMTP id ffacd0b85a97d-354faf5f1b4so359595f8f.1 for ; Thu, 23 May 2024 02:41:42 -0700 (PDT) Received: from EMEAENGAAD19049.citrite.net (0545937c.skybroadband.com. [5.69.147.124]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-354c7df311esm9533383f8f.3.2024.05.23.02.41.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 02:41:40 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: a967d2d5-18e8-11ef-90a1-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1716457302; x=1717062102; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5MpvoXLxrGjWD7P+YQJyPs2tsu37hmHqu/VshlrxEQE=; b=bn58ZUMTSS7bOUmaVgn26bU6QlUJGnZ2plx6tYKAvv7GTZCldzvJtGYvtHfCILsqad RuDHDRewvsCa2cVJ53eLr7YUGtvXJr+iDn29ZtOwpDHlj0etsbLLjBGd+azIm3rPDJfI vLQDIutdMvvNC0gyco5yBYU9GLvpZu0nRxcaY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716457302; x=1717062102; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=5MpvoXLxrGjWD7P+YQJyPs2tsu37hmHqu/VshlrxEQE=; b=dyCWLY8HOWRe94JjexgIATEvLYUhvgHH/WQdbMLc/RkrYEm8PwWGZNhLGBaTgikDcS qQCNQfuDIWkziAd0OHY81uYCgip+qCnk02iG4GfbdWOg2oszsTM1iy2MjiC9FaxTqYGE 2iyEFLg+cpVLEd2br4wK2DxdAH9sVEblU2l0344cBFfW3izeNnGgSCNx5ZR04rBLtipY De1XDbQ8cGiolrfF+tZ33pelnpbA9Lk53xLljqekBwu0phxqyFG/Nq/TUvhmnNtpVr8J l+SelTzVJBGg5AJsCWAG7K2EQ75aeRn4Ha9m/P0yWs0SD8k9R+dT6wfH5LfPBZGlAhLI 14mg== X-Gm-Message-State: AOJu0Yx6awJNQ3sD1TtuXze5S+4XgqDyi7nnVTUibFlNEREFNue8FeSi h9nYH7h5HVQXPZDwfOOeTqvzM1/IW7GHSv7ChDcH89JaFY2LqS641TcPM3no4UvXKPgS3BMga06 t X-Google-Smtp-Source: AGHT+IHWPgQ2tR8dl7xB4iECBSEd9EzERVPTZ4iCl7yTHZ0YMnhfSXuJ5ZYgsZjypjCFOC10ULwLZg== X-Received: by 2002:a5d:66c6:0:b0:354:f304:cd36 with SMTP id ffacd0b85a97d-354f304ce78mr2752759f8f.70.1716457301676; Thu, 23 May 2024 02:41:41 -0700 (PDT) From: Alejandro Vallejo To: Xen-devel Cc: Alejandro Vallejo , Anthony PERARD , Juergen Gross , Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= Subject: [PATCH v3 0/2] Clean the policy manipulation path in domain creation Date: Thu, 23 May 2024 10:41:28 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 v2 -> v3: * Style adjustments * Revert of loop index scope refactors v1 -> v2: * Removed xc_cpu_policy from xenguest.h (dropped v1/patch1) * Added accessors for xc_cpu_policy so the serialised form can be extracted. * Modified xen-cpuid to use accessors. ==== Original cover letter ==== In the context of creating a domain, we currently issue a lot of hypercalls redundantly while populating its CPU policy; likely a side effect of organic growth more than anything else. However, the worst part is not the overhead (this is a glacially cold path), but the insane amounts of boilerplate that make it really hard to pick apart what's going on. One major contributor to this situation is the fact that what's effectively "setup" and "teardown" phases in policy manipulation are not factored out from the functions that perform said manipulations, leading to the same getters and setter being invoked many times, when once each would do. Another big contributor is the code being unaware of when a policy is serialised and when it's not. This patch attempts to alleviate this situation, yielding over 200 LoC reduction. Patch 1: Mechanical change. Makes xc_cpu_policy_t public so it's usable from clients of libxc/libxg. Patch 2: Changes the (de)serialization wrappers in xenguest so they always serialise to/from the internal buffers of xc_cpu_policy_t. The struct is suitably expanded to hold extra information required. Patch 3: Performs the refactor of the policy manipulation code so that it follows a strict: PULL_POLICIES, MUTATE_POLICY (n times), PUSH_POLICY. Subject: [PATCH v3 0/2] *** SUBJECT HERE *** *** BLURB HERE *** Alejandro Vallejo (2): tools/xg: Streamline cpu policy serialise/deserialise calls tools/xg: Clean up xend-style overrides for CPU policies tools/include/xenguest.h | 8 +- tools/libs/guest/xg_cpuid_x86.c | 530 ++++++++++------------------ tools/libs/guest/xg_private.h | 2 + tools/libs/guest/xg_sr_common_x86.c | 56 ++- tools/misc/xen-cpuid.c | 41 +-- 5 files changed, 234 insertions(+), 403 deletions(-)