All of lore.kernel.org
 help / color / mirror / Atom feed
From: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Michal Hocko <mhocko-AlSwsSmVLrQ@public.gmane.org>
Cc: Tejun Heo <tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Anton Vorontsov
	<anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
	cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: workqueue usage in vmpressure
Date: Thu, 11 Jul 2013 16:43:08 +0800	[thread overview]
Message-ID: <51DE701C.6010800@huawei.com> (raw)
In-Reply-To: <20130711083110.GC21667-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>

> @@ -178,7 +179,7 @@ static void vmpressure_work_fn(struct work_struct *work)
>  	 * vmpr->reclaimed is in sync.
>  	 */
>  	if (!vmpr->scanned)
> -		return;
> +		goto out;
>  
>  	mutex_lock(&vmpr->sr_lock);
>  	scanned = vmpr->scanned;
> @@ -195,6 +196,13 @@ static void vmpressure_work_fn(struct work_struct *work)
>  		 * hierarchy.
>  		 */
>  	} while ((vmpr = vmpressure_parent(vmpr)));
> +out:
> +	/*
> +	 * Reference has been taken in vmpressure.
> +	 * memcg which embeds this vmpr might go away after this call so
> +	 * no further manipulation with vmprs or work item is safe
> +	 */
> +	vmpressure_unpin_memcg(vmpr);
>  }
>  
>  /**
> @@ -248,6 +256,9 @@ void vmpressure(gfp_t gfp, struct mem_cgroup *memcg,
>  
>  	if (scanned < vmpressure_win || work_pending(&vmpr->work))
>  		return;
> +
> +	/* Reference will be released in vmpressure_work_fn */
> +	vmpressure_pin_memcg(vmpr);
>  	schedule_work(&vmpr->work);

Looks like a work can be queued right after the above work_pending()
returns 0, then we should do this:

    if (schedule_work(&vmpr->work))
	vmpressure_pin_memcg(vmpr);

>  }
>  

  parent reply	other threads:[~2013-07-11  8:43 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-10 18:42 workqueue usage in vmpressure Tejun Heo
     [not found] ` <20130710184254.GA16979-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-11  8:31   ` Michal Hocko
     [not found]     ` <20130711083110.GC21667-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-11  8:43       ` Li Zefan [this message]
     [not found]         ` <51DE701C.6010800-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-07-11  9:25           ` Michal Hocko
     [not found]             ` <20130711092542.GD21667-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-11  9:28               ` Li Zefan
     [not found]                 ` <51DE7AAF.6070004-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-07-11  9:33                   ` [PATCH v2] vmpressure: make sure memcg stays alive until all users are signaled Michal Hocko
2013-07-11  9:33                     ` Michal Hocko
2013-07-11 15:44                     ` Tejun Heo
     [not found]                       ` <20130711154408.GA9229-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-11 16:22                         ` Michal Hocko
2013-07-11 16:22                           ` Michal Hocko
2013-07-11 16:32                           ` Tejun Heo
2013-07-12  8:40                             ` Michal Hocko
     [not found]                               ` <20130712084039.GA13224-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-12  9:20                                 ` Li Zefan
2013-07-12  9:20                                   ` Li Zefan
     [not found]                                   ` <51DFCA49.4080407-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2013-07-12  9:29                                     ` Michal Hocko
2013-07-12  9:29                                       ` Michal Hocko
     [not found]                                       ` <20130712092927.GA15307-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-12  9:54                                         ` Li Zefan
2013-07-12  9:54                                           ` Li Zefan
2013-07-12 10:37                                           ` Michal Hocko
     [not found]                                             ` <20130712103731.GB15307-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-15  3:07                                               ` Li Zefan
2013-07-15  3:07                                                 ` Li Zefan
2013-07-15  9:20                                                 ` Michal Hocko
     [not found]                                                   ` <20130715092033.GB26199-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-15  9:53                                                     ` Li Zefan
2013-07-15  9:53                                                       ` Li Zefan
2013-07-12  9:24                               ` [PATCH 1/3] vmpressure: document why css_get/put is not necessary for work queue based signaling Michal Hocko
2013-07-12  9:24                                 ` [PATCH 2/3] vmpressure: change vmpressure::sr_lock to spinlock Michal Hocko
     [not found]                                 ` <1373621098-15261-1-git-send-email-mhocko-AlSwsSmVLrQ@public.gmane.org>
2013-07-12  9:24                                   ` [PATCH 3/3] vmpressure: do not check for pending work to prevent from new work Michal Hocko
2013-07-12  9:24                                     ` Michal Hocko
2013-07-12 18:48                                 ` [PATCH 1/3] vmpressure: document why css_get/put is not necessary for work queue based signaling Tejun Heo
     [not found]                                   ` <20130712184836.GC23680-9pTldWuhBndy/B6EtB590w@public.gmane.org>
2013-07-15 10:27                                     ` Michal Hocko
2013-07-15 10:27                                       ` Michal Hocko
2013-07-12 18:34                               ` [PATCH v2] vmpressure: make sure memcg stays alive until all users are signaled Tejun Heo
2013-07-12 18:40                                 ` Tejun Heo
     [not found]                           ` <20130711162215.GM21667-2MMpYkNvuYDjFM9bn6wA6Q@public.gmane.org>
2013-07-12  6:03                             ` Li Zefan
2013-07-12  6:03                               ` Li Zefan
2013-07-15 10:30                         ` [PATCH v3 1/3] vmpressure: change vmpressure::sr_lock to spinlock Michal Hocko
2013-07-15 10:30                           ` Michal Hocko
2013-07-15 10:30                           ` [PATCH v3 2/3] vmpressure: do not check for pending work to prevent from new work Michal Hocko
2013-07-15 10:30                           ` [PATCH v3 3/3] vmpressure: Make sure there are no events queued after memcg is offlined Michal Hocko
2013-07-11  8:45       ` workqueue usage in vmpressure Li Zefan

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=51DE701C.6010800@huawei.com \
    --to=lizefan-hv44wf8li93qt0dzr+alfa@public.gmane.org \
    --cc=anton.vorontsov-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mhocko-AlSwsSmVLrQ@public.gmane.org \
    --cc=tj-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.