From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752804AbeAJWb2 (ORCPT + 1 other); Wed, 10 Jan 2018 17:31:28 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43582 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750782AbeAJWbZ (ORCPT ); Wed, 10 Jan 2018 17:31:25 -0500 Date: Wed, 10 Jan 2018 14:31:21 -0800 From: Andrew Morton To: Andrey Ryabinin Cc: Michal Hocko , Johannes Weiner , Vladimir Davydov , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Shakeel Butt Subject: Re: [PATCH v4] mm/memcg: try harder to decrease [memory,memsw].limit_in_bytes Message-Id: <20180110143121.cf2a1c5497b31642c9b38b2a@linux-foundation.org> In-Reply-To: <20180110124317.28887-1-aryabinin@virtuozzo.com> References: <20180109152622.31ca558acb0cc25a1b14f38c@linux-foundation.org> <20180110124317.28887-1-aryabinin@virtuozzo.com> X-Mailer: Sylpheed 3.4.1 (GTK+ 2.24.23; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On Wed, 10 Jan 2018 15:43:17 +0300 Andrey Ryabinin wrote: > mem_cgroup_resize_[memsw]_limit() tries to free only 32 (SWAP_CLUSTER_MAX) > pages on each iteration. This makes practically impossible to decrease > limit of memory cgroup. Tasks could easily allocate back 32 pages, > so we can't reduce memory usage, and once retry_count reaches zero we return > -EBUSY. > > Easy to reproduce the problem by running the following commands: > > mkdir /sys/fs/cgroup/memory/test > echo $$ >> /sys/fs/cgroup/memory/test/tasks > cat big_file > /dev/null & > sleep 1 && echo $((100*1024*1024)) > /sys/fs/cgroup/memory/test/memory.limit_in_bytes > -bash: echo: write error: Device or resource busy > > Instead of relying on retry_count, keep retrying the reclaim until > the desired limit is reached or fail if the reclaim doesn't make > any progress or a signal is pending. > Is there any situation under which that mem_cgroup_resize_limit() can get stuck semi-indefinitely in a livelockish state? It isn't very obvious that we're protected from this, so perhaps it would help to have a comment which describes how loop termination is assured?