From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:a19:c345:0:0:0:0:0 with SMTP id t66csp3787342lff; Sun, 12 Jan 2020 23:17:24 -0800 (PST) X-Google-Smtp-Source: APXvYqwVHDqOdcfVVR+xdlgzvRIjJbycyxM6/OizJivJFMxCGt1Kbdg1r9i1jCKkCLvLHcGwDeMn X-Received: by 2002:aca:481:: with SMTP id 123mr11867004oie.110.1578899844212; Sun, 12 Jan 2020 23:17:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578899844; cv=none; d=google.com; s=arc-20160816; b=BhsuePm7njyS1awBbeK+aqVWPUIdXkPYWu7Zr/sxmRuxHpXxn8VGIdTcrP529I88mg +HmxNhSlRP0KbOGFa6hRGzLfwcg82qyHSmbDrWMxBRHw7nV+euZUNTEzB4pPXrY2kwBV 5+3TQXR1sze9sqNZDgmfUM8Qdg/L8P3sgxnvOmTklDMB3B7rg5yYc6lrYGFCDA75opZd yOm6V5TvU+AjfR1p+Oih+tu5d0qtu0m4K7uTWHM33aoB85pXe3gKJZ4UMk8G23KS3QHK u/v0FAYjpYWERmkOkUhaSKViE3dA8uiarlKkhkcdeUNh5bHGmTqHDo9llHjPsJtqFwX/ YDWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ZNS+Y4j5xaHzZyLNm/Up0HYOeBmor+c+SYErPyrtn6I=; b=VHapMKGGiDQaTLDo/H5BZueC+EsEaK/SdFd056WgF3hVIqm0cKXjy6QxgEd7uGeb70 ha4K8QKAQf0BK/YiAFR5L7MBh+bV1/Hep+V/XXyPtlaVUeWY4oj+iAwd89Kf9e2v6VPK 7ZD2xE2zk5lRl5L3zROcHTzTVUKdmV9Tbz115ErUie7/1Hh3UwtbycAgmfg/HKRZqcZ3 AFD7H9eri9C9vikvjhFIoQQl5QcytmB23mfKkUd/0hbUEepGhSZx/vpdTMkvKvvnHoUY XqPhfke5TGzNzbLV1IJqii7+RoCelzxSWhth1f2tNgjR9U4TxtNhNvsyUfwd5JXGSryb AhUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b="W71Totl/"; spf=pass (google.com: best guess record for domain of kvm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=kvm-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d140si5438561oig.269.2020.01.12.23.17.23; Sun, 12 Jan 2020 23:17:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of kvm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gibson.dropbear.id.au header.s=201602 header.b="W71Totl/"; spf=pass (google.com: best guess record for domain of kvm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=kvm-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728598AbgAMHRW (ORCPT + 4 others); Mon, 13 Jan 2020 02:17:22 -0500 Received: from ozlabs.org ([203.11.71.1]:39785 "EHLO ozlabs.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725954AbgAMHRW (ORCPT ); Mon, 13 Jan 2020 02:17:22 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47x4fS2FYbz9sPn; Mon, 13 Jan 2020 18:17:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1578899840; bh=aaWWOD+aHSxJEi2O2Vs9dFgm1buPigAQBFB1/1ut62Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W71Totl//cINFjtMhIVRW6WMNQdvRrfxqhdWTzrYsJxfbAzzNzvD4PvtMsoMFIKl/ MI9mVhwOiw3rboglPy3O6t/L/rI2O37XWGyvdWRH+bsw70W9/tM1Vlp/ancQQqskw+ CgBVkElofU9uX4u2vscodtQKhBozqp39VCk/tApg= Date: Mon, 13 Jan 2020 17:16:48 +1000 From: David Gibson To: Greg Kurz Cc: Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , qemu-devel@nongnu.org, Peter Maydell , Eduardo Habkost , kvm@vger.kernel.org, Juan Quintela , qemu-ppc@nongnu.org, Marcelo Tosatti , "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, Alistair Francis , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eric Blake Subject: Re: [PATCH 04/15] hw/ppc/spapr_rtas: Restrict variables scope to single switch case Message-ID: <20200113071648.GF19995@umbus> References: <20200109152133.23649-1-philmd@redhat.com> <20200109152133.23649-5-philmd@redhat.com> <20200109184349.1aefa074@bahia.lan> <9870f8ed-3fa0-1deb-860d-7481cb3db556@redhat.com> <20200110105055.3e72ddf4@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XIiC+We3v3zHqZ6Z" Content-Disposition: inline In-Reply-To: <20200110105055.3e72ddf4@bahia.lan> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-TUID: aOdRxOIkJrHf --XIiC+We3v3zHqZ6Z Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 10, 2020 at 10:50:55AM +0100, Greg Kurz wrote: > On Fri, 10 Jan 2020 10:34:07 +0100 > Philippe Mathieu-Daud=E9 wrote: >=20 > > On 1/9/20 6:43 PM, Greg Kurz wrote: > > > On Thu, 9 Jan 2020 16:21:22 +0100 > > > Philippe Mathieu-Daud=E9 wrote: > > >=20 > > >> We only access these variables in RTAS_SYSPARM_SPLPAR_CHARACTERISTICS > > >> case, restrict their scope to avoid unnecessary initialization. > > >> > > >=20 > > > I guess a decent compiler can be smart enough detect that the initial= ization > > > isn't needed outside of the RTAS_SYSPARM_SPLPAR_CHARACTERISTICS branc= h... > > > Anyway, reducing scope isn't bad. The only hitch I could see is that = some > > > people do prefer to have all variables declared upfront, but there's = a nested > > > param_val variable already so I guess it's okay. > >=20 > > I don't want to outsmart compilers :) > >=20 > > The MACHINE() macro is not a simple cast, it does object introspection= =20 > > with OBJECT_CHECK(), thus is not free. Since=20 >=20 > Sure, I understand the motivation in avoiding an unneeded call > to calling object_dynamic_cast_assert(). >=20 > > object_dynamic_cast_assert() argument is not const, I'm not sure the=20 > > compiler can remove the call. > >=20 >=20 > Not remove the call, but delay it to the branch that uses it, > ie. parameter =3D=3D RTAS_SYSPARM_SPLPAR_CHARACTERISTICS. I think any performance consideration here is a red herring. This particular RTAS call is a handful-of-times-per-boot thing, and only AFAIK used by AIX guests. I'm in favour of the change on the grounds of code locality and readability. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --XIiC+We3v3zHqZ6Z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAl4cGWAACgkQbDjKyiDZ s5IRhxAAgjwTfn6oDce64WmxrtSzdp5v8NnkSL1fO3d3+2xEQyjHrPoCNGPjgsqG s05hIyZ+0BwiAKsdwmFtqnxsMdtwpNWDgzESv9t7aY3qRy3hZWj7b12sVkhio7nv 5LZ5VI0Brp0fGRv6Kw6/4KczI/rvWUKYYchMv027IyOdnK01hBLL0Le06RY4gUo4 ouZOKyF3NolvtBSxotq72UDJzlUeCACieg/xQuYo3DB2KT3HeerdYv4ijsF/vXpe yHgxJleALbk8XXfVGM2iXODKOuhbPE0Q1xovdzLZtw8Gc6LyRHlqS0PB4QVqu2pN 2W2ykFzPV52O5apL+Ythb03YgsbA15V02thgPWJgs8h3MEWaUOkkwuwmguJuZQnH 4jYeXOIY58Lwksts5+N8TiyuSAuepQiFTXFvysM9GUjt7aSDqW05Gg0b+heDyzyJ C00cQD+AzUJzFeRR75A8/bBzoeA2xTG8N2+CH2uinY2H3CBMHfy9V2DnzJChDwEL zkPr/tk2KT00dioTwNJFTyVivvZOzTWR8GbHxsM6+uOBiF/UwvyOQiJEHYcj2g/4 KFl9FaakjOqsjd3+tEOwyTmmIxlNNBBpphHYt+8ZKoYu344+Qp/E7brigCvhpC6+ x/YqfPajq/dqVh2mWqGNfEZyepvxWhQO2OglVhpd5WdTGP1x99U= =x52C -----END PGP SIGNATURE----- --XIiC+We3v3zHqZ6Z-- 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 X-Spam-Level: X-Spam-Status: No, score=-0.6 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3BE8C33CAE for ; Mon, 13 Jan 2020 07:18:08 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A0A342075B for ; Mon, 13 Jan 2020 07:18:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=gibson.dropbear.id.au header.i=@gibson.dropbear.id.au header.b="W71Totl/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A0A342075B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:46528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iqtzD-0005wF-Lc for qemu-devel@archiver.kernel.org; Mon, 13 Jan 2020 02:18:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44039) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iqtyZ-0005IC-U1 for qemu-devel@nongnu.org; Mon, 13 Jan 2020 02:17:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iqtyY-0002Lb-Oh for qemu-devel@nongnu.org; Mon, 13 Jan 2020 02:17:27 -0500 Received: from ozlabs.org ([203.11.71.1]:54233) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iqtyW-0002HD-2a; Mon, 13 Jan 2020 02:17:24 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 47x4fS2FYbz9sPn; Mon, 13 Jan 2020 18:17:20 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1578899840; bh=aaWWOD+aHSxJEi2O2Vs9dFgm1buPigAQBFB1/1ut62Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=W71Totl//cINFjtMhIVRW6WMNQdvRrfxqhdWTzrYsJxfbAzzNzvD4PvtMsoMFIKl/ MI9mVhwOiw3rboglPy3O6t/L/rI2O37XWGyvdWRH+bsw70W9/tM1Vlp/ancQQqskw+ CgBVkElofU9uX4u2vscodtQKhBozqp39VCk/tApg= Date: Mon, 13 Jan 2020 17:16:48 +1000 From: David Gibson To: Greg Kurz Subject: Re: [PATCH 04/15] hw/ppc/spapr_rtas: Restrict variables scope to single switch case Message-ID: <20200113071648.GF19995@umbus> References: <20200109152133.23649-1-philmd@redhat.com> <20200109152133.23649-5-philmd@redhat.com> <20200109184349.1aefa074@bahia.lan> <9870f8ed-3fa0-1deb-860d-7481cb3db556@redhat.com> <20200110105055.3e72ddf4@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="XIiC+We3v3zHqZ6Z" Content-Disposition: inline In-Reply-To: <20200110105055.3e72ddf4@bahia.lan> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Eduardo Habkost , kvm@vger.kernel.org, Juan Quintela , Marcelo Tosatti , qemu-devel@nongnu.org, "Dr. David Alan Gilbert" , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Paolo Bonzini , Alistair Francis , Philippe =?iso-8859-1?Q?Mathieu-Daud=E9?= , Richard Henderson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --XIiC+We3v3zHqZ6Z Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Jan 10, 2020 at 10:50:55AM +0100, Greg Kurz wrote: > On Fri, 10 Jan 2020 10:34:07 +0100 > Philippe Mathieu-Daud=E9 wrote: >=20 > > On 1/9/20 6:43 PM, Greg Kurz wrote: > > > On Thu, 9 Jan 2020 16:21:22 +0100 > > > Philippe Mathieu-Daud=E9 wrote: > > >=20 > > >> We only access these variables in RTAS_SYSPARM_SPLPAR_CHARACTERISTICS > > >> case, restrict their scope to avoid unnecessary initialization. > > >> > > >=20 > > > I guess a decent compiler can be smart enough detect that the initial= ization > > > isn't needed outside of the RTAS_SYSPARM_SPLPAR_CHARACTERISTICS branc= h... > > > Anyway, reducing scope isn't bad. The only hitch I could see is that = some > > > people do prefer to have all variables declared upfront, but there's = a nested > > > param_val variable already so I guess it's okay. > >=20 > > I don't want to outsmart compilers :) > >=20 > > The MACHINE() macro is not a simple cast, it does object introspection= =20 > > with OBJECT_CHECK(), thus is not free. Since=20 >=20 > Sure, I understand the motivation in avoiding an unneeded call > to calling object_dynamic_cast_assert(). >=20 > > object_dynamic_cast_assert() argument is not const, I'm not sure the=20 > > compiler can remove the call. > >=20 >=20 > Not remove the call, but delay it to the branch that uses it, > ie. parameter =3D=3D RTAS_SYSPARM_SPLPAR_CHARACTERISTICS. I think any performance consideration here is a red herring. This particular RTAS call is a handful-of-times-per-boot thing, and only AFAIK used by AIX guests. I'm in favour of the change on the grounds of code locality and readability. --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --XIiC+We3v3zHqZ6Z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAl4cGWAACgkQbDjKyiDZ s5IRhxAAgjwTfn6oDce64WmxrtSzdp5v8NnkSL1fO3d3+2xEQyjHrPoCNGPjgsqG s05hIyZ+0BwiAKsdwmFtqnxsMdtwpNWDgzESv9t7aY3qRy3hZWj7b12sVkhio7nv 5LZ5VI0Brp0fGRv6Kw6/4KczI/rvWUKYYchMv027IyOdnK01hBLL0Le06RY4gUo4 ouZOKyF3NolvtBSxotq72UDJzlUeCACieg/xQuYo3DB2KT3HeerdYv4ijsF/vXpe yHgxJleALbk8XXfVGM2iXODKOuhbPE0Q1xovdzLZtw8Gc6LyRHlqS0PB4QVqu2pN 2W2ykFzPV52O5apL+Ythb03YgsbA15V02thgPWJgs8h3MEWaUOkkwuwmguJuZQnH 4jYeXOIY58Lwksts5+N8TiyuSAuepQiFTXFvysM9GUjt7aSDqW05Gg0b+heDyzyJ C00cQD+AzUJzFeRR75A8/bBzoeA2xTG8N2+CH2uinY2H3CBMHfy9V2DnzJChDwEL zkPr/tk2KT00dioTwNJFTyVivvZOzTWR8GbHxsM6+uOBiF/UwvyOQiJEHYcj2g/4 KFl9FaakjOqsjd3+tEOwyTmmIxlNNBBpphHYt+8ZKoYu344+Qp/E7brigCvhpC6+ x/YqfPajq/dqVh2mWqGNfEZyepvxWhQO2OglVhpd5WdTGP1x99U= =x52C -----END PGP SIGNATURE----- --XIiC+We3v3zHqZ6Z--