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

Re: [PATCH] xen/balloon: use a kernel thread instead a workqueue


  • To: Juergen Gross <jgross@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx
  • From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
  • Date: Wed, 8 Sep 2021 10:47:16 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.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; bh=YxqmVh6FQ9ZKrX+i4+s2IIrwqHoUq4z1e+qAUQnB6WY=; b=llBxwXCpLhbZhUG9Tztiz4toFd4IYOrTISb9PojCS+/VkXAEv/GVOpv4m9RidTWTq8a8bd6LnMJxv3vpcWHUxbY5QzhDcUt7CqWjHuOXGSLagcqS3MGTIImOpHLMJl59r9CTzjYC9XaKosGVZ/GdaNwNYMFufu2RG0p83Tve9NohOWhZrWq9QVe7bCY6K4thcwV0kCLMq3wdfujXw3AHnWgJMpEptg+OP4LicBa0Y1hWi6prTe7mTDzvarO9Mmf7nz+WLQbXM9ECOhvckCTmq+WmiwlqG/D0e6Su4M5vIXwLyuZJBTgyBqh8qdBK94m82qcF2ITj3gwDS42ZuC9pjg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BiCenKX6nm3MJVWqYptB0kwZ2SAMAqbOTE4GzayzS7tp1S67nfnQunElxzNcb+haz+6aMe0FaookqVjR9l8oxO7hknKSQicfVLXLAtv+aZtQSE9AQIRabVDL/SLuU9NN02NoH+X/ZQ45jBFSDygyFynTONGnbzTwkB6UptUXKM0tkRULawOt418gzrVmSwqt8Z6obh2iOgidFl8rWmnjIOWyADfyJXfq22UGyp6sE+4OF7h6GUGk2TiSBZm5N/bha9qGHPj+dT8WoEexdllD9aQXnAuoNhH+Zka4kcJdAyKXj0tqpw0GVcRLk3nJcdG2gUoku6bfoArVujB6Umg/UA==
  • Authentication-results: suse.com; dkim=none (message not signed) header.d=none;suse.com; dmarc=none action=none header.from=oracle.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Wed, 08 Sep 2021 14:47:27 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 8/27/21 8:32 AM, Juergen Gross wrote:
> +static bool balloon_thread_cond(enum bp_state state, long credit)
> +{
> +     if (state != BP_EAGAIN)
> +             credit = 0;
> +
> +     return current_credit() != credit || kthread_should_stop();
> +}
> +
> +/*
> + * As this is a kthread it is guaranteed to run as a single instance only.
>   * We may of course race updates of the target counts (which are protected
>   * by the balloon lock), or with changes to the Xen hard limit, but we will
>   * recover from these in time.
>   */
> -static void balloon_process(struct work_struct *work)
> +static int balloon_thread(void *unused)
>  {
>       enum bp_state state = BP_DONE;
>       long credit;
> +     unsigned long timeout;
> +
> +     set_freezable();
> +     for (;;) {
> +             if (state == BP_EAGAIN)
> +                     timeout = balloon_stats.schedule_delay * HZ;
> +             else
> +                     timeout = 3600 * HZ;
> +             credit = current_credit();
>  
> +             wait_event_interruptible_timeout(balloon_thread_wq,
> +                              balloon_thread_cond(state, credit), timeout);


Given that wait_event_interruptible_timeout() is a bunch of nested macros do we 
need to worry here about overly aggressive compiler optimizing out 'credit = 
current_credit()'?


-boris





 


Rackspace

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