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

Re: [PATCH v6 1/3] evtchn: slightly defer lock acquire where possible


  • To: Julien Grall <julien@xxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Fri, 28 May 2021 10:30:59 +0200
  • 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-SenderADCheck; bh=3zRKekr4dj4xhs0PEWnqIXTmpu6fWZgo0v5jM1EFdXo=; b=Ym+ryaiuywXgCvQUaTQKQT3GBoSQlbym1hbPbcCzDoW6vlVKmWF5XCtIJ/t+sztAUM4oI2bt1q/sGdBSol77oxc0CNVdL8x65Xy3RtbuxZcQIrUtLyR3LcJ4BxP2woRNzLAdf4vragQ/KU/Te+BD90u1TscYrXV+R4MIlEX//wziXfyNFFBuzS/r4Fv7w2nYFxWixDlCOCNuDwNN4jxVwndDARu7/AB7kv5/W0Dc/9nB0s6TEzFBdpY+QqK3rlgA3eIwnpxRUvTx0RM2iXVjx3PRmjCz/h8HLVrnUvMEK9yeEyv9VWCj9yWX64AI1HSBgxOkOdpGWwhyU3uYw3Vx2Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OOMHDnXVMujszFhUsckOL6aeH6aNaDFunT75TvsnszVHEeJandrsn2yJ1r9Nn0k59mtljh7WYXxshUsCNa5hqEvEUTMIQPBtkLukAGQ0F0qY1dOadeOl5to1TN/5nOy4aarum0qsjm0pnF/KXboXpLKbAqID6ImE0JrmH7Sh9ipaxXDkwPYkN2ha16sVHEkT1ztTz9XK0ukevalqpCwkdW1RD/HmmXx/AwMxRcXPBarwYyZrCTPAenPqYsALDUeKVv5oIpBdqHEIvLusBKB1/obO30MJjaJ58I0akC/M/AQNLIM/eu8zOhV4qtmKasulPF1eKLqZagX90/IJULsAsw==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Jan Beulich <jbeulich@xxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Fri, 28 May 2021 08:31:25 +0000
  • Ironport-hdrordr: A9a23:Ek+iyqnb1UJjE1ykT2rSfm6zG+/pDfPXimdD5ihNYBxZY6Wkfp +V7ZcmPE7P6Ar5BktApTnZAtjwfZoYz+8B3WEQVY3SJTUOy1HYXL2KjLGSgwEIfheUh4xgPM hbAtVD4bHLfD9HZIPBkXeF+rUbsZq6GcKT9JvjJh5WJGkBBs8QinYcNuuCKCJLrUt9dOUE/f Knl456TlGbCAwqh7GAdwM4tp/41qb2ffzdEHg7Li9ixSy25AnYrYISJyLomSv2Hgk/m4vLPg D+4kLEDvHIiZ2G4y6Z81WWw4VdmdPnxNcGLteLkNIpJjLljRvtTJh9WpWZ1QpF892H2RIPqp 3hsh0gN8N85zf6ZWeuuybg3AHmzXIH92Li81mFmnHuyPaJFA7SM/Ax176xTyGptXbI/esMj5 6j5ljp66a/2CmwzRgU5LDzJlxXfwSP0DhSxNL6SRRkIM0jgfRq3P8iFXhuYeE99PiT0vF/LA AnNrCv2B93SyLDU5mLhBg1/DRbNk5DUStvfCA5y4eoO88/pgE086Jf/r1Dop4KzuN9d3Bg3Z WNDk1YrsAFciZNV9MLOA4oe7r/NoXie2O5DF6v
  • Ironport-sdr: UgEGSQDnKTCTBJhc3+RL1/5OZu/zdS7Pc8M6VMcb05oRY56GXZnz2AMpgrnZ91jJj62qpp89dt 7tlzDQfU8TAhiMfQ/Mi/o+bB+3DfapszNLMY5VrCCmoOeqoCL6jEKQZ+ygeqqFQ0NF/+/oO9Fp BVRuD4EVy4Ri9KmjMOTEuuwjHWvCtRGNDcmdJlQ2UVKqAf4VbLSNzixOv1jDlMdCqSbN3Xvhws ghT0Pph2rh9QnqPR3I/v4w4JPsDu0InixTv4MSLhy44s3OY4Wl0ZLZOLrNXqILqhnRaspLeaHJ 1rY=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Thu, May 27, 2021 at 07:48:41PM +0100, Julien Grall wrote:
> Hi Jan,
> 
> On 27/05/2021 12:28, Jan Beulich wrote:
> > port_is_valid() and evtchn_from_port() are fine to use without holding
> > any locks. Accordingly acquire the per-domain lock slightly later in
> > evtchn_close() and evtchn_bind_vcpu().
> 
> So I agree that port_is_valid() and evtchn_from_port() are fine to use
> without holding any locks in evtchn_bind_vcpu(). However, this is misleading
> to say there is no problem with evtchn_close().
> 
> evtchn_close() can be called with current != d and therefore, there is a

The only instances evtchn_close is called with current != d and the
domain could be unpaused is in free_xen_event_channel AFAICT.

> risk that port_is_valid() may be valid and then invalid because
> d->valid_evtchns is decremented in evtchn_destroy().

Hm, I guess you could indeed have parallel calls to
free_xen_event_channel and evtchn_destroy in a way that
free_xen_event_channel could race with valid_evtchns getting
decreased?

All callers of free_xen_event_channel are internal to the hypervisor,
so maybe with proper ordering of the operations this could be avoided,
albeit it's not easy to assert.

> Thankfully the memory is still there. So the current code is okayish and I
> could reluctantly accept this behavior to be spread. However, I don't think
> this should be left uncommented in both the code (maybe on top of
> port_is_valid()?) and the commit message.

Indeed, I think we need some expansion of the comment in port_is_valid
to clarify all this. I'm not sure I understand it properly myself when
it's fine to use port_is_valid without holding the per domain event
lock.

evtchn_close shouldn't be a very common operation anyway, so it
holding the per domain lock a bit longer doesn't seem that critical to
me anyway.

Thanks, Roger.



 


Rackspace

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