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

Re: [PATCH v2 8/8] x86/PV: use get_unsafe() instead of copy_from_unsafe()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Date: Tue, 23 Feb 2021 19:03:34 +0100
  • 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=HN5eKrFtSWC3HPsDBv8QE0Sl+p3T/8jC3D6N82xv25s=; b=fqLjaYEkAWME09e75hNxzwsZ5Kh+a5HXD4TTcyJLTm5eaSlt4tL6m+dNMZksJt1dmUWwb+4yXvPFGgOhPPHYuCX6/QPcGrqVLA/Ev/UZcmkITOiyb5O4Q9XTgzpoDZwJBtLZdqiB0VJxHRD3GJTQID83DUketM9sR14uk4Ft5SdF6hQZntcH76V+tP/Zeqf4uVAOEBtDRbzHhW7b9zf9Hj2BBfaqiWbLVRkRK/CpxXPsWyal5gkvhKzdcHdS6iPNrZMkzVZYTjtwakxoNBEjfEmzmvNG3xLw3kWscVSyC58grtakaaMpulnImVs+a38W5GUcL1/qDOlgSxLkWIeEpQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oun0jR8m1ZDozQMz0Qus/4tpoK4hcxls1G5qf/W3klaz4EXsOCkXeHGOcoTwXeqC5gw12y3X9Ys1aRlFISECKwt8a8tUaOurW11Ze9AcEQ/ZjHMFW5o/CWgTLKLm1QEe0mgsCAleIjWNz0iN2sapUEwoFgZKMKiKDGDoFfErFuK1MWNCnKzzEhHjE2PWIWxuwJBucbg7gAagAe0r+J6FzWvBZTV2GI4+GqJlikMFtyaF7F64H0S7x3tnw9bj8rz7gekgooZor5t1+PKuBZGE5HHkfX8DT+tMGB9/ijUbSwudbBtqngxZZWhmcu6N/rc2xcavz5pVGd1pJ7zng4DWBw==
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>
  • Delivery-date: Tue, 23 Feb 2021 18:03:45 +0000
  • Ironport-sdr: I/ga5D+mcVxz/gH5YPjhN8K4X1frv3S6d6GOTHkgwZhdWl/Nx9DIb/OpPGCbUVwBvadfEXhMpS iHC1yOnVB3r65vo7YX84jaKDL3p28PL6FISKDj1iweLiQCm7sELkFYitU5e5+OuA1seMXS+U9A LdSIhQHZwy5C7jRa8zzdxWyTvlcO5odXTR6OQBxfqQjMIcpp9EWHVRChOTL/iRhSxbxBtrQCzx BZWonwt9IG2YX1O77z3ngYQ4t6KhEAsQwv4hPf2TMKzsSJX1knreYaYLHHo3gZHch8tXRLRyS5 fMw=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Tue, Feb 23, 2021 at 05:13:21PM +0100, Jan Beulich wrote:
> On 23.02.2021 16:37, Roger Pau Monné wrote:
> > On Tue, Feb 23, 2021 at 04:25:00PM +0100, Jan Beulich wrote:
> >> On 23.02.2021 12:59, Roger Pau Monné wrote:
> >>> On Wed, Feb 17, 2021 at 09:23:33AM +0100, Jan Beulich wrote:
> >>>> The former expands to a single (memory accessing) insn, which the latter
> >>>> does not guarantee. Yet we'd prefer to read consistent PTEs rather than
> >>>> risking a split read racing with an update done elsewhere.
> >>>>
> >>>> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> >>>
> >>> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
> >>>
> >>> Albeit I wonder why the __builtin_constant_p check done in
> >>> copy_from_unsafe is not enough to take the get_unsafe_size branch in
> >>> there. Doesn't sizeof(l{1,2}_pgentry_t) qualify as a built time
> >>> constant?
> >>>
> >>> Or the fact that n it's a parameter to an inline function hides this,
> >>> in which case the __builtin_constant_p is pointless?
> >>
> >> Without (enough) optimization, __builtin_constant_p() may indeed
> >> yield false in such cases. But that wasn't actually what I had
> >> in mind when making this change (and the original similar on in
> >> shadow code). Instead, at the time I made the shadow side change,
> >> I had removed this optimization from the new function flavors.
> >> With that removal, things are supposed to still be correct - it's
> >> an optimization only, after all. Meanwhile the optimizations are
> >> back, so there's no immediate problem as long as the optimizer
> >> doesn't decide to out-of-line the function invocations (we
> >> shouldn't forget that even always_inline is not a guarantee for
> >> inlining to actually occur).
> > 
> > I'm fine with you switching those use cases to get_unsafe, but I think
> > the commit message should be slightly adjusted to notice that
> > copy_from_unsafe will likely do the right thing, but that it's simply
> > clearer to call get_unsafe directly, also in case copy_from_unsafe
> > gets changed in the future to drop the get_unsafe paths.
> 
> How about this then?
> 
> "The former expands to a single (memory accessing) insn, which the latter
>  does not guarantee (the __builtin_constant_p() based switch() statement
>  there is just an optimization). Yet we'd prefer to read consistent PTEs
>  rather than risking a split read racing with an update done elsewhere."

LGTM, thanks.

Roger.



 


Rackspace

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