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 C1220C433F5 for ; Fri, 25 Mar 2022 08:34:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355186AbiCYIgO (ORCPT ); Fri, 25 Mar 2022 04:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351420AbiCYIgM (ORCPT ); Fri, 25 Mar 2022 04:36:12 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 23A3049F11 for ; Fri, 25 Mar 2022 01:34:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648197278; h=from:from:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrdyQb+Uv/9WNCCF+/twDW82DyGh5taXBM+hU8QrQjU=; b=G13UsxorlXqmpZ4PHnHy2S2gm2wDVakLQX1qexIG0xnnpyAN6I6RSvIuCnqiwYP1SN0JFV v7TKZcQ4FyBnC6BaSLJanf4SUnhXkE+B3qHC3Ye6Q3u2pu5GeY3c5LBCUGdPO1tSTvfH5f V5B3E1pO836KOJMzfWll2BPWo0Gb1Sw= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-122-5v8A_A3SOPWoIFuGiFe96w-1; Fri, 25 Mar 2022 04:34:37 -0400 X-MC-Unique: 5v8A_A3SOPWoIFuGiFe96w-1 Received: by mail-wm1-f69.google.com with SMTP id z16-20020a05600c0a1000b0038bebbd8548so4940730wmp.3 for ; Fri, 25 Mar 2022 01:34:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:reply-to:date:message-id:mime-version :content-transfer-encoding; bh=WrdyQb+Uv/9WNCCF+/twDW82DyGh5taXBM+hU8QrQjU=; b=aTDrF7mLr6oYBsrk+2VBAwjAkpJGUdIAINZKE6o18+tkjJlu0KN940ulF7KgCGb2iz oRhW2K2RvBsvbOQJ0eek6hKJQTxlCV9Ke27isL28NPTELrO3kOacy+Toy5AAFCiEmx0K z209sfiMswxYAWY17VHDj2FWGYnJap+TrVbcsBnEfZAhXy+I6M6kuc6pe3BMiCtT6zke SVWp06vGPoigN6ppnT0pTB0bL59gEOB+v5IyEiZLTdN4A/5CBWasMFw5ubxvxC8ujzl+ uT6aU20QdcllHAPu9MhNA7y2fi+pXhqyxcTYAY9FpqTmnRyS+C/MrbEDkmtBknclJO3v ye3Q== X-Gm-Message-State: AOAM531mfqqsGx8lyji+oQpQszSfn+mqcgd+1OWbHScKmupjEvgAeA31 eI9AwghYKnd3sEIuBHxoXKpKygSicFdgnIJNnk7Jg2ol4hbsKEcmRfkDk2++dtmhnKkFfAxFyez ZvycXOzDnHpNH X-Received: by 2002:a05:600c:35cc:b0:38c:6d25:f4ad with SMTP id r12-20020a05600c35cc00b0038c6d25f4admr8589601wmq.127.1648197275905; Fri, 25 Mar 2022 01:34:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9JSpWRk2LRgPXv74WxLi/tJwLkB8FqTAgxuuKq0EB245CfQf7Z1SW9Vl2nq04SgzY/fLhZw== X-Received: by 2002:a05:600c:35cc:b0:38c:6d25:f4ad with SMTP id r12-20020a05600c35cc00b0038c6d25f4admr8589572wmq.127.1648197275657; Fri, 25 Mar 2022 01:34:35 -0700 (PDT) Received: from localhost ([47.63.10.52]) by smtp.gmail.com with ESMTPSA id n8-20020a5d5988000000b00203d5f1f3e4sm4828654wri.105.2022.03.25.01.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 01:34:35 -0700 (PDT) From: Juan Quintela To: marcandre.lureau@redhat.com Cc: qemu-devel@nongnu.org, Cameron Esfahani , Roman Bolshakov , Paolo Bonzini , David Hildenbrand , Igor Mammedov , Kevin Wolf , Hanna Reitz , Stefan Hajnoczi , Fam Zheng , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , "Denis V. Lunev" , Vladimir Sementsov-Ogievskiy , Warner Losh , Kyle Evans , "Michael S. Tsirkin" , Gerd Hoffmann , Eduardo Habkost , Marcel Apfelbaum , Yanan Wang , Cornelia Huck , Thomas Huth , Halil Pasic , Christian Borntraeger , Mark Cave-Ayland , =?utf-8?Q?C=C3=A9dric?= Le Goater , Daniel Henrique Barboza , David Gibson , Greg Kurz , Yuval Shaia , Stefan Berger , Alex Williamson , Richard Henderson , Peter Xu , Laurent Vivier , "Dr. David Alan Gilbert" , Markus Armbruster , Wenchao Wang , Colin Xu , Kamil Rytarowski , Reinoud Zandijk , Sunil Muthuswamy , Stefan Weil , kvm@vger.kernel.org (open list:Overall KVM CPUs), qemu-block@nongnu.org (open list:Block layer core), qemu-s390x@nongnu.org (open list:S390 general arch...), qemu-ppc@nongnu.org (open list:New World (mac99)), haxm-team@intel.com (open list:X86 HAXM CPUs) Subject: Re: [PATCH 11/32] Replace qemu_real_host_page variables with inlined functions In-Reply-To: <20220323155743.1585078-12-marcandre.lureau@redhat.com> (marcandre lureau's message of "Wed, 23 Mar 2022 19:57:22 +0400") References: <20220323155743.1585078-1-marcandre.lureau@redhat.com> <20220323155743.1585078-12-marcandre.lureau@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Reply-To: quintela@redhat.com Date: Fri, 25 Mar 2022 09:34:33 +0100 Message-ID: <87k0cie8h2.fsf@secure.mitica> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau > > Replace the global variables with inlined helper functions. getpagesize()= is very > likely annotated with a "const" function attribute (at least with glibc),= and thus > optimization should apply even better. > > This avoids the need for a constructor initialization too. > > Signed-off-by: Marc-Andr=C3=A9 Lureau I see what you are tyring to do here. But once here, why aren't we just calling getpagesize() and call it a day? I can't see what advantage has to have this other name for this function, and as you are already changing all its uses anyways. Once there, I can see that qemu_real_host_page_mask is used (almost) everywhere as (vfio code use the real value): foo & qemu_real_host_page_mask() or foo & ~qemu_real_host_page_mask() And no, I don't have any good names for this macros. Anyways, if you don't like the suggestion, your changes are better that we already have, so ... Reviewed-by: Juan Quintela 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) (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 4A78FC433F5 for ; Fri, 25 Mar 2022 08:36:37 +0000 (UTC) Received: from localhost ([::1]:51684 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nXfQx-0007pZ-MR for qemu-devel@archiver.kernel.org; Fri, 25 Mar 2022 04:36:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXfP8-0006lx-CN for qemu-devel@nongnu.org; Fri, 25 Mar 2022 04:34:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:36095) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nXfP5-0004h1-H5 for qemu-devel@nongnu.org; Fri, 25 Mar 2022 04:34:40 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648197278; h=from:from:reply-to: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WrdyQb+Uv/9WNCCF+/twDW82DyGh5taXBM+hU8QrQjU=; b=G13UsxorlXqmpZ4PHnHy2S2gm2wDVakLQX1qexIG0xnnpyAN6I6RSvIuCnqiwYP1SN0JFV v7TKZcQ4FyBnC6BaSLJanf4SUnhXkE+B3qHC3Ye6Q3u2pu5GeY3c5LBCUGdPO1tSTvfH5f V5B3E1pO836KOJMzfWll2BPWo0Gb1Sw= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-313-xQf-_uNvNMO75kpJPFnbow-1; Fri, 25 Mar 2022 04:34:37 -0400 X-MC-Unique: xQf-_uNvNMO75kpJPFnbow-1 Received: by mail-wm1-f72.google.com with SMTP id l7-20020a05600c1d0700b0038c9c48f1e7so4945421wms.2 for ; Fri, 25 Mar 2022 01:34:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:reply-to:date:message-id:mime-version :content-transfer-encoding; bh=WrdyQb+Uv/9WNCCF+/twDW82DyGh5taXBM+hU8QrQjU=; b=Weprr8yl65xL6jQOoI0C04/uGWW1+NfK4+71raf1JFbvyU3zUR8hgZcrN1PUJ6qLh4 kiLA2Ccc9JDzUOqRW1zm+g5CdWx604ysMyrA7OYvpn7IPxhtoOJ7/l6/T+22mn2PVlbI e2j0+Rk+ZwmHGoENaqlM2C6h6wmvb2Q51Le3TI1NxyKPkwZ4BO6bJvgKivwRPOyH1Q41 kUNMHYMw/EzmRRjRRkCb+hUhTmsYfNnLYb5APFuT/Kg4KUdSrPDh2DyOWYi7KplCgWWe cxr/Z5u5RBcgUYudcZ0Qz8mbmMe+U5vWIzG4ren6iJ3maKK36su8ifND6akwp+U0//gV dtjw== X-Gm-Message-State: AOAM532dNVJynDIdGlBr1k4rvNthWhqrIJATvSP/9X4441VOdf1/0VRm ikQYg/ufNAnn5Crf3aBe98MjesDetlOQXA+BYpom8M8al55zH9HTXaL9CJAWx3ChSK1/BJcepHD +i2M8NXmfC3G5Rx4= X-Received: by 2002:a05:600c:35cc:b0:38c:6d25:f4ad with SMTP id r12-20020a05600c35cc00b0038c6d25f4admr8589647wmq.127.1648197276070; Fri, 25 Mar 2022 01:34:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9JSpWRk2LRgPXv74WxLi/tJwLkB8FqTAgxuuKq0EB245CfQf7Z1SW9Vl2nq04SgzY/fLhZw== X-Received: by 2002:a05:600c:35cc:b0:38c:6d25:f4ad with SMTP id r12-20020a05600c35cc00b0038c6d25f4admr8589572wmq.127.1648197275657; Fri, 25 Mar 2022 01:34:35 -0700 (PDT) Received: from localhost ([47.63.10.52]) by smtp.gmail.com with ESMTPSA id n8-20020a5d5988000000b00203d5f1f3e4sm4828654wri.105.2022.03.25.01.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 01:34:35 -0700 (PDT) From: Juan Quintela To: marcandre.lureau@redhat.com Subject: Re: [PATCH 11/32] Replace qemu_real_host_page variables with inlined functions In-Reply-To: <20220323155743.1585078-12-marcandre.lureau@redhat.com> (marcandre lureau's message of "Wed, 23 Mar 2022 19:57:22 +0400") References: <20220323155743.1585078-1-marcandre.lureau@redhat.com> <20220323155743.1585078-12-marcandre.lureau@redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) Date: Fri, 25 Mar 2022 09:34:33 +0100 Message-ID: <87k0cie8h2.fsf@secure.mitica> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=quintela@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.129.124; envelope-from=quintela@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -21 X-Spam_score: -2.2 X-Spam_bar: -- X-Spam_report: (-2.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: quintela@redhat.com Cc: Fam Zheng , Daniel Henrique Barboza , "open list:Overall KVM CPUs" , David Hildenbrand , Mark Cave-Ayland , qemu-devel@nongnu.org, Peter Xu , Laurent Vivier , Yanan Wang , "open list:X86 HAXM CPUs" , Gerd Hoffmann , "Denis V. Lunev" , Warner Losh , Alex Williamson , qemu-block@nongnu.org, Stefan Berger , "Michael S. Tsirkin" , Markus Armbruster , Halil Pasic , Kamil Rytarowski , Reinoud Zandijk , Stefan Weil , Christian Borntraeger , Eduardo Habkost , Thomas Huth , Vladimir Sementsov-Ogievskiy , Kyle Evans , Richard Henderson , Greg Kurz , Cameron Esfahani , Yuval Shaia , Roman Bolshakov , =?utf-8?Q?C=C3=A9dric?= Le Goater , Stefan Hajnoczi , Paolo Bonzini , Sunil Muthuswamy , David Gibson , Kevin Wolf , "open list:S390 general arch..." , Cornelia Huck , Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= , Hanna Reitz , "open list:New World mac99" , Wenchao Wang , Igor Mammedov , "Dr. David Alan Gilbert" , Colin Xu Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" marcandre.lureau@redhat.com wrote: > From: Marc-Andr=C3=A9 Lureau > > Replace the global variables with inlined helper functions. getpagesize()= is very > likely annotated with a "const" function attribute (at least with glibc),= and thus > optimization should apply even better. > > This avoids the need for a constructor initialization too. > > Signed-off-by: Marc-Andr=C3=A9 Lureau I see what you are tyring to do here. But once here, why aren't we just calling getpagesize() and call it a day? I can't see what advantage has to have this other name for this function, and as you are already changing all its uses anyways. Once there, I can see that qemu_real_host_page_mask is used (almost) everywhere as (vfio code use the real value): foo & qemu_real_host_page_mask() or foo & ~qemu_real_host_page_mask() And no, I don't have any good names for this macros. Anyways, if you don't like the suggestion, your changes are better that we already have, so ... Reviewed-by: Juan Quintela