[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH for-4.17 v3 07/15] CODING_STYLE(tools/ocaml): add 'make format' and remove tabs


  • To: Henry Wang <Henry.Wang@xxxxxxx>
  • From: Edwin Torok <edvin.torok@xxxxxxxxxx>
  • Date: Wed, 9 Nov 2022 14:18:15 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c8eKovsa9/zAjjj2eEXHy3G9ERh7s5T6IgK4RZzjVC4=; b=Ow+bAFDjkr1ZFQMAD9ulSXwtR0nGaipwXXhFP0GKpTldG1NcAyh8QeqvcRIjBfaS3ittaOow3WLFBmFwRoM0mI+2FCkBRwNj1mmIVj6bvIDPsfUTgYJSYTr4owk6B9lMWgHmxHqUHyOqzCf8zia923tZYGcp1SVjls/ZEgehp8CTxv3iTvq9KUXwfFKn0NgpvBoC0fUx35Jj8/rV7o4BbjVnFHScAhBJFwLTXWRuLxIlOTM+uYgAzKdku+AmI3ENodsbk+3J0XC3RL6+S3o0ja9TCtXoE/DNLCgmL3W0oogBKDtXy40kFIZ1WdiKiXSXwU7LRYeCwmHPKO63KzSWfw==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Tw0Wh+PHwFenlJzaKo0SK7ICQnzjX3sOChVvpihciijRRSlVVTfq9B2X9c45SsYDCYRz5BB5ra5v/WQiq3yirrCBysTAe9oWSpuxNa491c8rmpC+yq+H1oq32Dl8ul06ufotCpGNaVU4u0aFMCU3GgMBF7HZqpLd8P5RY9O2cCkV3eQ0kdVfJ0ZlLS4FUkwSbwAh98euE1hqBHRuiyDd1JIM9ht2PN3ZemNinQGhyRvmd1TFaRf1iKmc0Bg6NHoO9Nby/LYqQQZmp2n7/vTjKW0/v/LJlXQB5PUKxKxF2azCZs+/TpHa3kVNraGgN6Ew5a0Ln+Zsr5S8zxnynhj2nA==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: Julien Grall <julien@xxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Christian Lindig <christian.lindig@xxxxxxxxxx>, David Scott <dave@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>
  • Delivery-date: Wed, 09 Nov 2022 14:18:30 +0000
  • Ironport-data: A9a23:sTYhRaJ96fL0D2KYFE+REZQlxSXFcZb7ZxGr2PjKsXjdYENSgTFSy GocXDqObKyKMzCke413ad609k0CsZGHydJnTFFlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHv+kUrWs1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPdwP9TlK6q4mlB5wRvPaojUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVaPpIAHOgdcS9qZwChxLid/ jnvWauYEm/FNoWU8AgUvoIx/ytWZcWq85efSZSzXFD6I+QrvBIAzt03ZHzaM7H09c4qJWxHy aACJAk3dx6kpLiXmIyRRs5V05FLwMnDZOvzu1lG5BSBUbMKZM6GRK/Ho9hFwD03m8ZCW+7EY NYUYiZuaxKGZABTPlAQC9Q1m+LAanvXKmUE7g7K4/VspTSMpOBy+OGF3N79d9CURMMTgkGCo WHu9GXlGBAKcteYzFJp91r83bKSx3qlA+r+EpXnrsYzjgSDz1UOSzwnTUHrjqm0oAmHDoc3x 0s8v3BGQbIJ3GymSMPsGSKxpnGstwQZHdFXFoUS6hyJy6fSyxaUAC4DVDEpQMwrsoo6SCIn0 neNnsj1Hnp/vbuNU3Wf+7yI6zSoNkA9IWYcaAceQAAC4t2lp5s85jrQSv5zHajzicf6cQwc2 BiPpSk6wrkW08gC0v3n+Uid227z4J/UUgQy+wPbGHq/6R90b5KkYIru7kXH6fFHL8CSSVzpU GU4pvVyJdsmVfml/BFhis1RdF11z55p6AHhvGM=
  • Ironport-hdrordr: A9a23:wrHWIa/cbd9gRP88Xchuk+F7db1zdoMgy1knxilNoENuH/Bwxv rFoB1E73TJYW4qKQodcdDpAtjifZtFnaQFrLX5To3SJjUO31HYYL2KjLGSiQEIfheTygcz79 YGT0ETMrzN5B1B/L7HCWqDYpkdKbu8gcaVbI7lph8DIz2CKZsQljuRYTzrcHGeMTM2YabRY6 Dsg/avyQDBRV0nKuCAQlUVVenKoNPG0Lj8ZwQdOhIh4A6SyRu19b/TCXGjr1YjegIK5Y1n3X nOkgT/6Knmmeq80AXg22ja6IkTsMf9y+FEGNeHhqEuW3XRY0eTFcdcso+5zXUISdKUmRIXeR 730lAd1vFImjHsl6eO0F3QMkfboW8TAjTZuCKlaDPY0LDErXQBeoR8bMtiA2Xkwltls9dm3K 1R2WWF85JREBPbhSz4o8PFThdwiyOP0DMfeX56tQ0hbWIyUs4nkWUkxjIiLL4QWCbhrIw3Gu hnC8/RoP5QbFOBdnjc+m1i2salUHg/FgqPBhFqgL3f7xFG2HRii0cIzs0WmXkNsJo7Vplf/u zBdqBljqtHQMMaZb90QO0BXcy0AGrQRg+kChPbHX33UKUcf37doZ/+57s4oOmsZZwT1ZM33I /MVVtJ3FRCD34Gyff+qaGj3iq9M1lVBw6du/22z6IJyoHUVf7sLTCJTkwono+pv+gfa/erKc qOBA==
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHY84fA+Ym2JRve3kKJcIO1APAKeK41MEgAgACx3ICAAML3gA==
  • Thread-topic: [PATCH for-4.17 v3 07/15] CODING_STYLE(tools/ocaml): add 'make format' and remove tabs


> On 9 Nov 2022, at 02:40, Henry Wang <Henry.Wang@xxxxxxx> wrote:
> 
> Hi Julien,
> 
>> -----Original Message-----
>> From: Julien Grall <julien@xxxxxxx>
>> Subject: Re: [PATCH for-4.17 v3 07/15] CODING_STYLE(tools/ocaml): add
>> 'make format' and remove tabs
>> While I understand the goal and support, this seems to be a bit too late
>> to do it in Xen 4.17 (we are only a couple of weeks away). At this stage
>> of the release we should only do bug fix.
>> 
>> This is clearly only a comesmetic change and there I would argue this
>> should be deferred to 4.18. That said the last call is from the RM.
> 
> I agree with your point. I think maybe defer the patch to 4.18 is better,
> given the deep freeze state we are currently in.

On the other hand here is a bug I just spotted when looking at indentation 
changes (or rather reading the code after the indentation change),
and there are probably more:

```
        if not (Domain.get_io_credit dom > 0) then
            debug "Looking up domid %d" (Domain.get_id dom);
-           let con = Connections.find_domain cons (Domain.get_id dom) in
-           if not (Connection.has_more_work con) then (
-               Process.do_output store cons domains con;
-               Process.do_input store cons domains con;
-               if Connection.has_more_work con then
-                   (* Previously thought as no work, but detect some after 
scan (as
-                      processing a new message involves multiple steps.) It's 
very
-                      likely to be a "lazy" client, bump its credit. It could 
be false
-                      positive though (due to time window), but it's no harm 
to give a
-                      domain extra credit. *)
-                   let n = 32 + 2 * (Domains.number domains) in
-                   info "found lazy domain %d, credit %d" (Domain.get_id dom) 
n;
-                   Domain.set_io_credit ~n dom
-           ) in
+       let con = Connections.find_domain cons (Domain.get_id dom) in
+       if not (Connection.has_more_work con) then (
+           Process.do_output store cons domains con;
+           Process.do_input store cons domains con;
+           if Connection.has_more_work con then
+               (* Previously thought as no work, but detect some after scan (as
+                  processing a new message involves multiple steps.) It's very
+                  likely to be a "lazy" client, bump its credit. It could be 
false
+                  positive though (due to time window), but it's no harm to 
give a
+                  domain extra credit. *)
+               let n = 32 + 2 * (Domains.number domains) in
+               info "found lazy domain %d, credit %d" (Domain.get_id dom) n;
+               Domain.set_io_credit ~n dom
+       ) in
```

Notice how all that code "seems" to be inside the if unless you read really 
closely, but in fact it isn't, just the debug statement is.
Which means whenever I reviewed this code (to look for performance or security 
bugs) I've been reading it wrong the same way the original author got it wrong 
when indenting it.
In this case the original author being me, as I've introduced this bug in 
42f0581a91d4340ae66768a29fd779f83415bdfe back in 2021, where prior to the 
change in that commit indentation was correct,
but the patch added the 'debug' line in the wrong place (before the let instead 
of after it, and had I had my usual tools available to indent the file correctly
this problem would've been detected and corrected before commiting the bug into 
the codebase...
And was probably a side-effect of trying not to reindent the code to reduce the 
patch size for the security fix, and by doing so introducing an actual 
functional bug
)
(And I've recently fixed a similar bug elsewhere in XAPI, in which case I 
wasn't the original author of such a bug)
Indentation can't really be trusted to humans :)

(It means that even if a domain already has IO credit we still scan its ring 
for more work)

So some indentation changes will probably come in as bugfixes for 4.17.1 (well 
maybe not reindenting the whole file, just the problematic region of 
code/function).

Best regards,
--Edwin


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.