WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

Re: [Xen-devel] [PATCH 6 of 9] xenpaging: add evict_pages function

To: Ian Campbell <Ian.Campbell@xxxxxxxxxx>
Subject: Re: [Xen-devel] [PATCH 6 of 9] xenpaging: add evict_pages function
From: George Dunlap <dunlapg@xxxxxxxxx>
Date: Thu, 15 Sep 2011 10:05:46 +0100
Cc: Olaf Hering <olaf@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxx>
Delivery-date: Thu, 15 Sep 2011 02:07:59 -0700
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=mX7Qy552bYH9YXzV5mWbYw/2gticdk1C/p7T27obnvM=; b=dNRej5gLdxWSoqUZvSn2RL+v7Cc56oeQ706gZfJ3MXiS0+ssIBahRGAKtmFSdJRZ7B eSWb7jL2MAMfFQ5o8PlW9fjbJMJJEgW5ft3vg9PPqGhOMHvbON1duKuACz76kRVvO5+L rbNJxo+rxnkLs4busaPD7FPyw5Au8IDpBNADA=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <1316074602.25935.4.camel@xxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <patchbomb.1316067388@xxxxxxxxxxxx> <3a3a5979b799d9488021.1316067394@xxxxxxxxxxxx> <1316074602.25935.4.camel@xxxxxxxxxxxxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
On Thu, Sep 15, 2011 at 9:16 AM, Ian Campbell <Ian.Campbell@xxxxxxxxxx> wrote:
> On Thu, 2011-09-15 at 02:16 -0400, Olaf Hering wrote:
>> # HG changeset patch
>> # User Olaf Hering <olaf@xxxxxxxxx>
>> # Date 1316067230 -7200
>> # Node ID 3a3a5979b799d948802183d10d65894ee84a872f
>> # Parent  6beca8cbc2c92900859712f8738db17084bcebdb
>> xenpaging: add evict_pages function
>>
>> Add new function to evict a couple of pages.
>
> Do you really mean "a couple" here? (that generally means exactly two).

LIterally "couple" means two, but at least in US idiom, "a couple of
[foo]" means a small indeterminate number, usually 2-4.

In any case, a more precise description seems like a better idea -- it
looks like it takes an argument for the number of pages to evict; and
it's not adding a new function, it's pulling existing code into a
function.  So, "Pull eviction loop into a function" would probably be
a better description.

 -George

> >From the implementation I think you mean evict a batch of pages?
>
>> Allocate all possible slots in a paging file to allow growing and
>> shrinking of the number of paged-out pages. Adjust other places to
>> iterate over all slots.
>>
>> This change is required by subsequent patches.
>>
>> Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>
>>
>> diff -r 6beca8cbc2c9 -r 3a3a5979b799 tools/xenpaging/xenpaging.c
>> --- a/tools/xenpaging/xenpaging.c
>> +++ b/tools/xenpaging/xenpaging.c
>> @@ -597,6 +597,30 @@ static int evict_victim(xenpaging_t *pag
>>      return ret;
>>  }
>>
>> +/* Evict a couple of pages and write them to a free slot in the paging file 
>> */
>> +static int evict_pages(xenpaging_t *paging, int fd, xenpaging_victim_t 
>> *victims, int num_pages)
>> +{
>> +    xc_interface *xch = paging->xc_handle;
>> +    int rc, slot, num = 0;
>> +
>> +    for ( slot = 0; slot < paging->max_pages && num < num_pages; slot++ )
>> +    {
>> +        /* Slot is allocated */
>> +        if ( victims[slot].gfn != INVALID_MFN )
>> +            continue;
>> +
>> +        rc = evict_victim(paging, &victims[slot], fd, slot);
>> +        if ( rc == -ENOSPC )
>> +            break;
>> +        if ( rc == -EINTR )
>> +            break;
>> +        if ( num && num % 100 == 0 )
>> +            DPRINTF("%d pages evicted\n", num);
>> +        num++;
>> +    }
>> +    return num;
>> +}
>> +
>>  int main(int argc, char *argv[])
>>  {
>>      struct sigaction act;
>> @@ -639,7 +663,12 @@ int main(int argc, char *argv[])
>>          return 2;
>>      }
>>
>> -    victims = calloc(paging->num_pages, sizeof(xenpaging_victim_t));
>> +    /* Allocate upper limit of pages to allow growing and shrinking */
>> +    victims = calloc(paging->max_pages, sizeof(xenpaging_victim_t));
>> +
>> +    /* Mark all slots as unallocated */
>> +    for ( i = 0; i < paging->max_pages; i++ )
>> +        victims[i].gfn = INVALID_MFN;
>>
>>      /* ensure that if we get a signal, we'll do cleanup, then exit */
>>      act.sa_handler = close_handler;
>> @@ -653,18 +682,7 @@ int main(int argc, char *argv[])
>>      /* listen for page-in events to stop pager */
>>      create_page_in_thread(paging);
>>
>> -    /* Evict pages */
>> -    for ( i = 0; i < paging->num_pages; i++ )
>> -    {
>> -        rc = evict_victim(paging, &victims[i], fd, i);
>> -        if ( rc == -ENOSPC )
>> -            break;
>> -        if ( rc == -EINTR )
>> -            break;
>> -        if ( i % 100 == 0 )
>> -            DPRINTF("%d pages evicted\n", i);
>> -    }
>> -
>> +    i = evict_pages(paging, fd, victims, paging->num_pages);
>>      DPRINTF("%d pages evicted. Done.\n", i);
>>
>>      /* Swap pages in and out */
>> @@ -690,13 +708,13 @@ int main(int argc, char *argv[])
>>              if ( test_and_clear_bit(req.gfn, paging->bitmap) )
>>              {
>>                  /* Find where in the paging file to read from */
>> -                for ( i = 0; i < paging->num_pages; i++ )
>> +                for ( i = 0; i < paging->max_pages; i++ )
>>                  {
>>                      if ( victims[i].gfn == req.gfn )
>>                          break;
>>                  }
>>
>> -                if ( i >= paging->num_pages )
>> +                if ( i >= paging->max_pages )
>>                  {
>>                      DPRINTF("Couldn't find page %"PRIx64"\n", req.gfn);
>>                      goto out;
>>
>> _______________________________________________
>> Xen-devel mailing list
>> Xen-devel@xxxxxxxxxxxxxxxxxxx
>> http://lists.xensource.com/xen-devel
>
>
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@xxxxxxxxxxxxxxxxxxx
> http://lists.xensource.com/xen-devel
>

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel