From patchwork Thu May 11 15:44:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 92713 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4478140vqo; Thu, 11 May 2023 08:48:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7nzIlMCWXKRTU+f4eB0Eg6lPz7wZ4TffQwvO1RTHO7D6W8+Z7/hwakm4LDYUkeTSq/Kzkp X-Received: by 2002:a17:90a:8c17:b0:24d:f3cc:7d34 with SMTP id a23-20020a17090a8c1700b0024df3cc7d34mr21788646pjo.32.1683820097830; Thu, 11 May 2023 08:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683820097; cv=none; d=google.com; s=arc-20160816; b=krCmaOrUHrKUhwaWYhGjBWUOS4sjb6lQcmiWW0JzxDOHRgfMdhD1hZL6TtR6LqTb3n dTY3IvpmqLKNVOJWTV6ptARFC5Q+u1zT0N7HnkzwmJ2B91a+JoWmabWliynWrYqBJxux o1fPRKiKzbBGL/SDGTCEBNwRugXMrlGkvx5VvMkBZHj3meharkQ3QqukFH+sEa64PW6U XfrZaL4anq3vjD9PpdcKz79VEEe9I/8zg08/4MJ9KrBIejr8h5BFZ/0FT0lOgNHN5Km0 AsD8ralBEftoD+XqwZVWfq6cekyBNY15vuXWXr/A+TygGtxSpoalu5wWi2ljz4W9wpW8 m8hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=6hA5uGGu0ozvSKvJzmBCCeO6og/chPIFFGMh5VY0v6c=; b=GEBsyNFheEaIhMd7FKPbYP4DemZvenmjs3wfbgVx59IH8fF06pzwlrhYN2kv+COBzI RzMGwuyYMJ/THz8sTTIzOrrzk3vGvapguAWjn8jDsFT6FITsNV5lezOEp4UAV/PrQKWh Qsf+I5xAuw3SxrBxqMR8c/fspJB7OAH6hVi8Y2V/Swgqb2ID9RaVUiazKYS6FXnvOgwZ 5u/z0RIegghe5EQ6E0EkfBHfuNI7PfPdFXamtW2RSkeo25fJP4oc9rt2ygfVGBUTuOmo bl/wlhtEtsAunoCqUqa2K6FmZPiX1MGNNkpXaqHt0DEx5e2oahuSsqduJDJdEAib80fk trNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BPNojPFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nn4-20020a17090b38c400b00250d2935d98si5707243pjb.3.2023.05.11.08.47.53; Thu, 11 May 2023 08:48:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=BPNojPFC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238857AbjEKPpZ (ORCPT + 99 others); Thu, 11 May 2023 11:45:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36272 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238807AbjEKPpC (ORCPT ); Thu, 11 May 2023 11:45:02 -0400 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CABA459E6; Thu, 11 May 2023 08:45:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1683819901; x=1715355901; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=8QfQokLJef1Q3tFm7nj3VQwR9R1wsoZXkMCX5UZhwws=; b=BPNojPFC3PGuF7jA9DOxYrp/IK0Im2Yc7OlGDSoE8pXAj5cr6Q+j/7Ak Xfezzqdb5jBnbjDMJuC3C5pM1lXk1mtXPeBdJhBoMXBCcbZPpy/ROkyFg ruaCJYS4utdagSZg2zMQZeV6agfUMHoG8hd3l4ejiuqditARbQ6lArfWL EXHCHALL+D9+c7vNUumzfxuTIyGDbsCcIm/N6HdEs1HYbS7lQe/UHwXh0 r5Ia3PcxiZr1ID5QNQQAqF8mw3+5I+BdhURa00JulqXHrCqQ6Shdkr0Ch /TMHDDyujC/KrCCEFpdFSA4AqYRioowUmRmoq2n59K5uuJqENAMpXG97W Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="335046685" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="335046685" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 08:44:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10707"; a="699776242" X-IronPort-AV: E=Sophos;i="5.99,266,1677571200"; d="scan'208";a="699776242" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by orsmga002-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2023 08:44:48 -0700 From: Reinette Chatre To: jgg@nvidia.com, yishaih@nvidia.com, shameerali.kolothum.thodi@huawei.com, kevin.tian@intel.com, alex.williamson@redhat.com Cc: tglx@linutronix.de, darwi@linutronix.de, kvm@vger.kernel.org, dave.jiang@intel.com, jing2.liu@intel.com, ashok.raj@intel.com, fenghua.yu@intel.com, tom.zanussi@linux.intel.com, reinette.chatre@intel.com, linux-kernel@vger.kernel.org Subject: [PATCH V5 08/11] vfio/pci: Use bitfield for struct vfio_pci_core_device flags Date: Thu, 11 May 2023 08:44:35 -0700 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765613342647571465?= X-GMAIL-MSGID: =?utf-8?q?1765613342647571465?= struct vfio_pci_core_device contains eleven boolean flags. Boolean flags clearly indicate their usage but space usage starts to be a concern when there are many. An upcoming change adds another boolean flag to struct vfio_pci_core_device, thereby increasing the concern that the boolean flags are consuming unnecessary space. Transition the boolean flags to use bitfields. On a system that uses one byte per boolean this reduces the space consumed by existing flags from 11 bytes to 2 bytes with room for a few more flags without increasing the structure's size. Suggested-by: Jason Gunthorpe Signed-off-by: Reinette Chatre Reviewed-by: Kevin Tian --- Changes since V4: - Add Kevin's Reviewed-by tag. (Kevin) Changes since V3: - New patch. (Jason) include/linux/vfio_pci_core.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/include/linux/vfio_pci_core.h b/include/linux/vfio_pci_core.h index 148fd1ae6c1c..adb47e2914d7 100644 --- a/include/linux/vfio_pci_core.h +++ b/include/linux/vfio_pci_core.h @@ -68,17 +68,17 @@ struct vfio_pci_core_device { u16 msix_size; u32 msix_offset; u32 rbar[7]; - bool pci_2_3; - bool virq_disabled; - bool reset_works; - bool extended_caps; - bool bardirty; - bool has_vga; - bool needs_reset; - bool nointx; - bool needs_pm_restore; - bool pm_intx_masked; - bool pm_runtime_engaged; + bool pci_2_3:1; + bool virq_disabled:1; + bool reset_works:1; + bool extended_caps:1; + bool bardirty:1; + bool has_vga:1; + bool needs_reset:1; + bool nointx:1; + bool needs_pm_restore:1; + bool pm_intx_masked:1; + bool pm_runtime_engaged:1; struct pci_saved_state *pci_saved_state; struct pci_saved_state *pm_save; int ioeventfds_nr;