xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Boris Ostrovsky <boris.ostrovsky@oracle.com>
To: Juergen Gross <jgross@suse.com>,
	xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org
Cc: Stefano Stabellini <sstabellini@kernel.org>,
	Jan Beulich <jbeulich@suse.com>
Subject: Re: [PATCH] xen/balloon: use a kernel thread instead a workqueue
Date: Wed, 8 Sep 2021 10:47:16 -0400	[thread overview]
Message-ID: <8b13525b-0075-f4c1-8900-1be151e85e3e@oracle.com> (raw)
In-Reply-To: <20210827123206.15429-1-jgross@suse.com>


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




  reply	other threads:[~2021-09-08 14:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-27 12:32 [PATCH] xen/balloon: use a kernel thread instead a workqueue Juergen Gross
2021-09-08 14:47 ` Boris Ostrovsky [this message]
2021-09-08 15:11   ` Juergen Gross
2021-09-08 16:05     ` Boris Ostrovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b13525b-0075-f4c1-8900-1be151e85e3e@oracle.com \
    --to=boris.ostrovsky@oracle.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).