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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 6BAF0C3815B for ; Mon, 20 Apr 2020 12:15:10 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 2E7E4206B9 for ; Mon, 20 Apr 2020 12:15:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2E7E4206B9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQVKD-00014X-TZ; Mon, 20 Apr 2020 12:14:57 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1jQVKC-00014Q-HY for xen-devel@lists.xenproject.org; Mon, 20 Apr 2020 12:14:56 +0000 X-Inumbo-ID: 8b91a62c-8300-11ea-9055-12813bfff9fa Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 8b91a62c-8300-11ea-9055-12813bfff9fa; Mon, 20 Apr 2020 12:14:55 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id BBA0CABAD; Mon, 20 Apr 2020 12:14:53 +0000 (UTC) Subject: Re: [PATCH 05/17] xen/x86: Remove the non-typesafe version of pagetable_* helpers To: Julien Grall References: <20200322161418.31606-1-julien@xen.org> <20200322161418.31606-6-julien@xen.org> <2be87441-05a6-6b58-23e3-da467230ffe7@xen.org> <6af445d8-636f-a19e-ac53-9c66ae9f61c5@suse.com> <0bb49716-6b1c-0beb-01c5-4c0d220ca011@xen.org> From: Jan Beulich Message-ID: Date: Mon, 20 Apr 2020 14:14:51 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <0bb49716-6b1c-0beb-01c5-4c0d220ca011@xen.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Kevin Tian , Wei Liu , Andrew Cooper , Julien Grall , Tim Deegan , George Dunlap , Jun Nakajima , xen-devel@lists.xenproject.org, =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" On 20.04.2020 12:10, Julien Grall wrote: > Hi, > > On 20/04/2020 10:16, Jan Beulich wrote: >> On 18.04.2020 12:23, Julien Grall wrote: >>> On 30/03/2020 08:52, Jan Beulich wrote: >>>> On 28.03.2020 11:52, Julien Grall wrote: >>>>> On 26/03/2020 15:39, Jan Beulich wrote: >>>>>> On 22.03.2020 17:14, julien@xen.org wrote: >>>>>>> @@ -3116,24 +3116,24 @@ int vcpu_destroy_pagetables(struct vcpu *v) >>>>>>>           /* Free that page if non-zero */ >>>>>>>         do { >>>>>>> -        if ( mfn ) >>>>>>> +        if ( !mfn_eq(mfn, _mfn(0)) ) >>>>>> >>>>>> I admit I'm not fully certain either, but at the first glance >>>>>> >>>>>>            if ( mfn_x(mfn) ) >>>>>> >>>>>> would seem more in line with the original code to me (and then >>>>>> also elsewhere). >>>>> >>>>> It is doing *exactly* the same things. The whole point of typesafe >>>>> is to use typesafe helper not open-coding test everywhere. >>>>> >>>>> It is also easier to spot any use of MFN 0 within the code as you >>>>> know could grep "_mfn(0)". >>>>> >>>>> Therefore I will insist to the code as-is. >>>> >>>> What I insit on is that readability of the result of such changes be >>>> also kept in mind. The mfn_eq() construct is (I think) clearly less >>>> easy to read and recognize than the simpler alternative suggested. >>> >>> If mfn_eq() is less clear, then where do you draw the line when the >>> macro should or not be used? >> >> I'm afraid there may not be a clear line to draw until everything >> got converted. > > I am sorry but this doesn't add up. Here you say that we can't have > a clear line to draw until everything is converted but... > >> I do seem to recall though that, perhaps in a >> different context, Andrew recently agreed with my view here (Andrew, >> please correct me if I'm wrong). It being a fuzzy thing, I guess >> maintainers get to judge ... > > ... here you say the maintainers get to decide when to use mfn_eq() > (or other typesafe construction). So basically, we would never be > able to fully convert the code and therefore never draw a line. Why? Eventually both sides of an mfn_eq() will be of type mfn_t. And in the specific case hand even with my alternative suggestion no further change would be needed down the road. Type safety is for things like function argument passing and assignments and alike. A leaf expression like "if ( mfn_x() )" is not type-unsafe in any way. Jan