Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3184300ybi; Mon, 29 Jul 2019 02:21:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqwID5no/DU/GCxPBqSDeObJFIl/eC0ck5Yo6udMt2CaJAECUTOmSw3sdbefIkvxgEXDt4mp X-Received: by 2002:a17:902:28:: with SMTP id 37mr101067305pla.188.1564392097068; Mon, 29 Jul 2019 02:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564392097; cv=none; d=google.com; s=arc-20160816; b=TC4FjT/v7CJfVle8+JamKJo20EmgP8Tv278eQOjHKF1SKztZmMYhWrop9jwr9RtODw o7yMQjnCH/Cz8QXeqcTjhLDa+3tRUiZZgyYjYoS39MLi5gJefPbe8cqa2+PU6UpEzAzu itwC+cHuE19l0nuRuEZmUfAlxe1FNB+7QajJcqC6n8xEOXGnuT51Xgvq8oK45y68Q/jT YQLyLJYGrJHa25LJflzz9nmcTO/0pTLFo6IkcR6WGbIng6pUTuGEn9TED7KxHvdtf0TG w+EByFiEATRvB6gWxalLiQFWrRJuvDetYmG9ZTR9JoLCIqazEwSj1MoFYqgjeMU8MFin xfXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=iNNe+WWPHMeC8bUtBPXbVDY36//V6+aGdo5wx5TBPYY=; b=ecKWI/VyZPWMlC8EyQnjvBU7QF06qg5jqGXVo/hphpIc5vYqy5YZl/dYSjA4/3I2zM 6M8ciRJreb6lZ4dKX9sHdML6Gw6eNt9YhCqUIRJD9MbRkgG//1JXlYftY91YIVsTeGxd ogVmjSgDILdeouLXtRWQ3I08YLXQcWdee4o4dD4T3EPzXMoLQuiWHyh/cno5GA0idxq8 p42pxyLgAJhm77oULHUE0BalxuLWqXQ275sqPXsHjvuL4YcjXHEUGbkMjzTZgjeChP2/ rnTun2Zcl/bG9fvhSUpxyK3NBPJgWuxSqSlnPeOuXlDJk1RI7gmHkrnS9BsdxQQplKaQ Ypbw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w62si25827491pgd.209.2019.07.29.02.21.22; Mon, 29 Jul 2019 02:21:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727645AbfG2JRk (ORCPT + 99 others); Mon, 29 Jul 2019 05:17:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:34460 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726496AbfG2JRk (ORCPT ); Mon, 29 Jul 2019 05:17:40 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2C442AEFD; Mon, 29 Jul 2019 09:17:39 +0000 (UTC) Date: Mon, 29 Jul 2019 11:17:38 +0200 From: Michal Hocko To: Konstantin Khlebnikov Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, Vladimir Davydov , Johannes Weiner Subject: Re: [PATCH RFC] mm/memcontrol: reclaim severe usage over high limit in get_user_pages loop Message-ID: <20190729091738.GF9330@dhcp22.suse.cz> References: <156431697805.3170.6377599347542228221.stgit@buzz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <156431697805.3170.6377599347542228221.stgit@buzz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun 28-07-19 15:29:38, Konstantin Khlebnikov wrote: > High memory limit in memory cgroup allows to batch memory reclaiming and > defer it until returning into userland. This moves it out of any locks. > > Fixed gap between high and max limit works pretty well (we are using > 64 * NR_CPUS pages) except cases when one syscall allocates tons of > memory. This affects all other tasks in cgroup because they might hit > max memory limit in unhandy places and\or under hot locks. > > For example mmap with MAP_POPULATE or MAP_LOCKED might allocate a lot > of pages and push memory cgroup usage far ahead high memory limit. > > This patch uses halfway between high and max limits as threshold and > in this case starts memory reclaiming if mem_cgroup_handle_over_high() > called with argument only_severe = true, otherwise reclaim is deferred > till returning into userland. If high limits isn't set nothing changes. > > Now long running get_user_pages will periodically reclaim cgroup memory. > Other possible targets are generic file read/write iter loops. I do see how gup can lead to a large high limit excess, but could you be more specific why is that a problem? We should be reclaiming the similar number of pages cumulatively. -- Michal Hocko SUSE Labs