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

Re: [PATCH v7 02/10] xen/domain: Add vmtrace_frames domain creation parameter


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Mon, 25 Jan 2021 17:17:50 +0000
  • 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=k+E/m1jdPGxJSVzx9pg2xeFVN/RCDQ552GuAra5/gR0=; b=YtXSGgk2KqdHUriDg0PWFKFexe/nkmecONdw2ERvv5zonufvtJ/qwBa/lIWvUmSr+zJ2qwpcS28nE8coLDfddZPkjEqt/ywRaVzKtzT4rkxu4mfCQMKKS8qhpBwIZhsryLMHeKqQuJ+cJetuy4VrxodnnB89BeAX5Jvs4awMHimoPBy2zmt7mdNClwPW2jotTAomKuobelR5dl2VRMSxrSnyMtnZqzCWoQfCySf3vxqMuV5OyExcTLSwPsU/Mj77qcxcdKimiMuaOhWV9n0RV3uggyvfGPLJCZO+xgh2ik+dP7oaXCHcDPw3EGNVKIkgSEQPGu5k+pNHNbAP5N7ooA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KdIPbtdixOS600K15jm5RSpy7dwdSs3Cgt/mUDupkNfnVqC7E8ZaRnI07qReTZ2KoXuGePNJHe9GRO4H9JKyuFuVhFNm7ApRDL2jF/wPvYwZu/YyhzJS7s9DMqAGjDxe3Vz31xq+G2MWyjZVYBGeLNvmfNZez36M5joLvnFbBPNPYGmrovF/iFq65NvvW+xlVvFtmDu0yUPRoRb/TeENTRRyE0zbFK9dyJH5krbdgx0AYw35208m+d5D7hm7f9en6TKrPVn1CE9AZhKoyoFJzd0DFp9GlrQ5BBClBLE4e/aVJebl+4UFVvcoegI+0ch2vb8U4krhw1ds3q02pFpeGA==
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: Michał Leszczyński <michal.leszczynski@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Mon, 25 Jan 2021 17:18:30 +0000
  • Ironport-sdr: VeOJjNfafU/b95QELGCu6SLxN0Jk2+kFUaFV2xSoY1JmGW7SJGPbZg0Nc9BYVwlKTvZpLgDBJA n53O/5RbazmZv2zJLNMpH10CHm25e3WkoFBRP6gH8dL1WVr5DSLE2Gg62CLEA62SBaJrr+Mw/d WpibM7eC2/u2Qdh5BXKPskt4uj2I+gQxQexXByqJgPzaCWHZtVnmbTvKHcNVcti91H70347Nj3 KNS4wQjpSCTsPpudBeppYeWUECSAhEPlpTkF6LR0GYZpr5JWEYOn+AmXu/9awOWqYzxBrTmEdZ FSQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 25/01/2021 15:08, Jan Beulich wrote:
> On 21.01.2021 22:27, Andrew Cooper wrote:
>> --- a/xen/common/domain.c
>> +++ b/xen/common/domain.c
>> @@ -132,6 +132,48 @@ static void vcpu_info_reset(struct vcpu *v)
>>      v->vcpu_info_mfn = INVALID_MFN;
>>  }
>>  
>> +static void vmtrace_free_buffer(struct vcpu *v)
>> +{
>> +    const struct domain *d = v->domain;
>> +    struct page_info *pg = v->vmtrace.buf;
>> +    unsigned int i;
>> +
>> +    if ( !pg )
>> +        return;
>> +
>> +    for ( i = 0; i < d->vmtrace_frames; i++ )
>> +    {
>> +        put_page_alloc_ref(&pg[i]);
>> +        put_page_and_type(&pg[i]);
>> +    }
>> +
>> +    v->vmtrace.buf = NULL;
> To set a good precedent, maybe this wants moving up ahead of
> the loop and ...
>
>> +}
>> +
>> +static int vmtrace_alloc_buffer(struct vcpu *v)
>> +{
>> +    struct domain *d = v->domain;
>> +    struct page_info *pg;
>> +    unsigned int i;
>> +
>> +    if ( !d->vmtrace_frames )
>> +        return 0;
>> +
>> +    pg = alloc_domheap_pages(d, get_order_from_pages(d->vmtrace_frames),
>> +                             MEMF_no_refcount);
>> +    if ( !pg )
>> +        return -ENOMEM;
>> +
>> +    v->vmtrace.buf = pg;
> ... this wants moving down past the loop, to avoid
> globally announcing something that isn't fully initialized
> yet / anymore?

Fine.

>
>> +    for ( i = 0; i < d->vmtrace_frames; i++ )
>> +        /* Domain can't know about this page yet - something fishy going 
>> on. */
>> +        if ( !get_page_and_type(&pg[i], d, PGT_writable_page) )
>> +            BUG();
> Whatever the final verdict to the other similar places
> that one of your patch changes should be applied here,
> too.

Obviously, except there's 0 room for manoeuvring on that patch, so this
hunk is correct.

>
>> --- a/xen/include/public/domctl.h
>> +++ b/xen/include/public/domctl.h
>> @@ -94,6 +94,7 @@ struct xen_domctl_createdomain {
>>      uint32_t max_evtchn_port;
>>      int32_t max_grant_frames;
>>      int32_t max_maptrack_frames;
>> +    uint32_t vmtrace_frames;
> Considering page size related irritations elsewhere in the
> public interface, could you have a comment clarify the unit
> of this value (Xen's page size according to the rest of the
> patch), and that space will be allocated once per-vCPU
> rather than per-domain (to stand a chance of recognizing
> the ultimate memory footprint resulting from this)?

Well - its hopefully obvious that it shares the same units as the other
*_frames parameters.

But yes - the future ABI fixes, it will be forbidden to use anything in
units of frames, to fix the multitude of interface bugs pertaining to
non-4k page sizes.

I'll switch to using vmtrace_size, in units of bytes, and the per-arch
filtering can enforce being a multiple of 4k.

>
>> --- a/xen/include/xen/sched.h
>> +++ b/xen/include/xen/sched.h
>> @@ -257,6 +257,10 @@ struct vcpu
>>      /* vPCI per-vCPU area, used to store data for long running operations. 
>> */
>>      struct vpci_vcpu vpci;
>>  
>> +    struct {
>> +        struct page_info *buf;
>> +    } vmtrace;
> While perhaps minor, I'm unconvinced "buf" is a good name
> for a field of this type.

Please suggest a better one then.  This one is properly namespaced as
v->vmtrace.buf which is the least bad option I could come up with.

>
>> @@ -470,6 +474,9 @@ struct domain
>>      unsigned    pbuf_idx;
>>      spinlock_t  pbuf_lock;
>>  
>> +    /* Used by vmtrace features */
>> +    uint32_t    vmtrace_frames;
> unsigned int? Also could you move this to an existing 32-bit
> hole, like immediately after "monitor"?

Ok.

~Andrew



 


Rackspace

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