From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vladimir Davydov Subject: Re: [PATCH] swap: cond_resched in swap_cgroup_prepare() Date: Sat, 3 Jun 2017 17:58:26 +0300 Message-ID: <20170603145826.GA15130@esperanza> References: <20170601195635.20744-1-yuzhao@google.com> Mime-Version: 1.0 Return-path: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=UUsyf5QzAXgojmxUabJo1wwb4NpXBXMuYTVdQkVKoUc=; b=Cy9SkEKrcjhTmd4Frx/lR9bjjuRZH/vNpF10UH3XZLpY7sgc4eHeHr3eO+je7r5DwZ JDsntAJqeS/bIQIuKJREW5+11DplE2dQWxT5W89YnmO4CxGtBRl73W6IkPPK9+rPg0kW y6LpIm6YpgRiSDveyASBN2nAhbgbwYFsUQccuj9vX1vPrXaJdauU/GgeFoyKxyuxhL4w 8DAoDEHzvxUHl7hm9N3rf0nMxtFn+syMXKv6bKfb3+8xiaCvIdqQfxeOJmwZNM0cBP5N OGBVtygS7UoAA5ViD1j0Y57C0r136aWEq5rIUUVYjz7RJhdX/6H3Mrva+eweqMqP1HHt N9bA== Content-Disposition: inline In-Reply-To: <20170601195635.20744-1-yuzhao-hpIqsD4AKlfQT0dZR+AlfA@public.gmane.org> Sender: cgroups-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Yu Zhao Cc: Johannes Weiner , Michal Hocko , cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, linux-mm-Bw31MaZKKs3YtjvyW6yDsg@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org On Thu, Jun 01, 2017 at 12:56:35PM -0700, Yu Zhao wrote: > Saw need_resched() warnings when swapping on large swapfile (TBs) > because page allocation in swap_cgroup_prepare() took too long. > > We already cond_resched when freeing page in swap_cgroup_swapoff(). > Do the same for the page allocation. > > Signed-off-by: Yu Zhao Acked-by: Vladimir Davydov > --- > mm/swap_cgroup.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c > index ac6318a064d3..3405b4ee1757 100644 > --- a/mm/swap_cgroup.c > +++ b/mm/swap_cgroup.c > @@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type) > if (!page) > goto not_enough_page; > ctrl->map[idx] = page; > + > + if (!(idx % SWAP_CLUSTER_MAX)) > + cond_resched(); > } > return 0; > not_enough_page: We should probably do the same on the error path. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf0-f71.google.com (mail-lf0-f71.google.com [209.85.215.71]) by kanga.kvack.org (Postfix) with ESMTP id 0A81E6B0292 for ; Sat, 3 Jun 2017 10:58:31 -0400 (EDT) Received: by mail-lf0-f71.google.com with SMTP id o139so21068501lfe.15 for ; Sat, 03 Jun 2017 07:58:30 -0700 (PDT) Received: from mail-lf0-x242.google.com (mail-lf0-x242.google.com. [2a00:1450:4010:c07::242]) by mx.google.com with ESMTPS id h138si15343084lfg.422.2017.06.03.07.58.29 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Jun 2017 07:58:29 -0700 (PDT) Received: by mail-lf0-x242.google.com with SMTP id v20so3684967lfa.2 for ; Sat, 03 Jun 2017 07:58:29 -0700 (PDT) Date: Sat, 3 Jun 2017 17:58:26 +0300 From: Vladimir Davydov Subject: Re: [PATCH] swap: cond_resched in swap_cgroup_prepare() Message-ID: <20170603145826.GA15130@esperanza> References: <20170601195635.20744-1-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170601195635.20744-1-yuzhao@google.com> Sender: owner-linux-mm@kvack.org List-ID: To: Yu Zhao Cc: Johannes Weiner , Michal Hocko , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org On Thu, Jun 01, 2017 at 12:56:35PM -0700, Yu Zhao wrote: > Saw need_resched() warnings when swapping on large swapfile (TBs) > because page allocation in swap_cgroup_prepare() took too long. > > We already cond_resched when freeing page in swap_cgroup_swapoff(). > Do the same for the page allocation. > > Signed-off-by: Yu Zhao Acked-by: Vladimir Davydov > --- > mm/swap_cgroup.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c > index ac6318a064d3..3405b4ee1757 100644 > --- a/mm/swap_cgroup.c > +++ b/mm/swap_cgroup.c > @@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type) > if (!page) > goto not_enough_page; > ctrl->map[idx] = page; > + > + if (!(idx % SWAP_CLUSTER_MAX)) > + cond_resched(); > } > return 0; > not_enough_page: We should probably do the same on the error path. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751195AbdFCO6c (ORCPT ); Sat, 3 Jun 2017 10:58:32 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34274 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750876AbdFCO6a (ORCPT ); Sat, 3 Jun 2017 10:58:30 -0400 Date: Sat, 3 Jun 2017 17:58:26 +0300 From: Vladimir Davydov To: Yu Zhao Cc: Johannes Weiner , Michal Hocko , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] swap: cond_resched in swap_cgroup_prepare() Message-ID: <20170603145826.GA15130@esperanza> References: <20170601195635.20744-1-yuzhao@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170601195635.20744-1-yuzhao@google.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 01, 2017 at 12:56:35PM -0700, Yu Zhao wrote: > Saw need_resched() warnings when swapping on large swapfile (TBs) > because page allocation in swap_cgroup_prepare() took too long. > > We already cond_resched when freeing page in swap_cgroup_swapoff(). > Do the same for the page allocation. > > Signed-off-by: Yu Zhao Acked-by: Vladimir Davydov > --- > mm/swap_cgroup.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/mm/swap_cgroup.c b/mm/swap_cgroup.c > index ac6318a064d3..3405b4ee1757 100644 > --- a/mm/swap_cgroup.c > +++ b/mm/swap_cgroup.c > @@ -48,6 +48,9 @@ static int swap_cgroup_prepare(int type) > if (!page) > goto not_enough_page; > ctrl->map[idx] = page; > + > + if (!(idx % SWAP_CLUSTER_MAX)) > + cond_resched(); > } > return 0; > not_enough_page: We should probably do the same on the error path.