Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp347344pxb; Wed, 24 Feb 2021 03:59:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJxetHKWv7R/qFXxa7goDNQEbU7CQ3P8s0fEIV/QwIY5CbPS/OlYgPv8obGiDecLKdq3ih9w X-Received: by 2002:aa7:d295:: with SMTP id w21mr18473697edq.159.1614167978046; Wed, 24 Feb 2021 03:59:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614167978; cv=none; d=google.com; s=arc-20160816; b=yoOcW38sCY0fdq98jvIhgx69HwsyQZvrTMp/XIc6EzGdfwV0ryiuu+KoLvszzEYFns wMBXNUxqp4j4wWgtOnUIqmubIWNfvm166jqQGb6DbbYsiqN3s0CkpxgSu/Lz9tkwvoG+ 6liLm6ZGcBJ1P7OLKhnDmTMlAF7ucyErUKzslfanwwrX+0mrhWr4/MW/SCfAd9gWHDLR 6k4UdPuEpb4s1kd7nJ0tbmNVJWzKo1Wfa/82vcVMmZ3tgq4iGHo+GpP432FYIT0c9nn/ rJlp7OiEvPkQIWL78pABojQ6H9Ilq/GqffDQ72Kuc0ayP7ZUeKzt1rgUjhxwispogudp itvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XzLsHGcL8bQEwd8q77IJXXPxrQFmDs82g85prap2dQ4=; b=plME8xIUy2S00CihqMxC5i9wgOHg+jJx9J/7qf+oSIdcIWQh6zcOp4eIFmuWHnDI+c +axLyzChOB3Xv+cTDlKJF4abI0xnEckjIAg6UAQg0XfySAWrLuiCvlWbcZ8W7yHBu/ON vct1DSA5Uyyhn26ITDoN5ogpOPui3wXYSg0VwCDpJxjapjJLqWXNARF9TAf/DJKMZhio WD5CfgOlp3PQwkRgMR1Y3Cf+QoC/vtkGHh/q2+m9LdZ46ZinIdctBpdXZf+FXG8DfAXe oIaBCtVyYAC3r0JYXFpXUHHxQkFxfEoO+Y8sIZ52WMRFWaCTCy+JekRHJXTepLnjGSRf Z2Nw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nXir09DK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q17si1032495edr.358.2021.02.24.03.59.14; Wed, 24 Feb 2021 03:59:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=nXir09DK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235198AbhBXLz4 (ORCPT + 99 others); Wed, 24 Feb 2021 06:55:56 -0500 Received: from mx2.suse.de ([195.135.220.15]:59490 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235192AbhBXLyY (ORCPT ); Wed, 24 Feb 2021 06:54:24 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1614167617; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=XzLsHGcL8bQEwd8q77IJXXPxrQFmDs82g85prap2dQ4=; b=nXir09DKObx9wu/my6Ugn5gdRgCXHFR7PCmDobwcx3KpR14Hr90pvWZwBEJmLtYJWI0B6R /7z86SKpQROZRhKPQ27B778WIRwrt3MZQrt6wYpdGaX1fLA4BtZg0qAxf16zW7CAYZFcpg onHSk/VsZtl2Lnilzk6yEZSaiE8fcvk= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 71AE5ADDB; Wed, 24 Feb 2021 11:53:37 +0000 (UTC) Date: Wed, 24 Feb 2021 12:53:35 +0100 From: Michal Hocko To: Tim Chen Cc: Andrew Morton , Johannes Weiner , Vladimir Davydov , Dave Hansen , Ying Huang , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 2/3] mm: Force update of mem cgroup soft limit tree on usage excess Message-ID: References: <06f1f92f1f7d4e57c4e20c97f435252c16c60a27.1613584277.git.tim.c.chen@linux.intel.com> <884d7559-e118-3773-351d-84c02642ca96@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 22-02-21 11:48:37, Tim Chen wrote: > > > On 2/22/21 11:09 AM, Michal Hocko wrote: > > >> > >> I actually have tried adjusting the threshold but found that it doesn't work well for > >> the case with unenven memory access frequency between cgroups. The soft > >> limit for the low memory event cgroup could creep up quite a lot, exceeding > >> the soft limit by hundreds of MB, even > >> if I drop the SOFTLIMIT_EVENTS_TARGET from 1024 to something like 8. > > > > What was the underlying reason? Higher order allocations? > > > > Not high order allocation. > > The reason was because the run away memcg asks for memory much less often, compared > to the other memcgs in the system. So it escapes the sampling update and > was not put onto the tree and exceeds the soft limit > pretty badly. Even if it was put onto the tree and gets page reclaimed below the > limit, it could escape the sampling the next time it exceeds the soft limit. I am sorry but I really do not follow. Maybe I am missing something obvious but the the rate of events (charge/uncharge) shouldn't be really important. There is no way to exceed the limit without charging memory (either a new or via task migration in v1 and immigrate_on_move). If you have SOFTLIMIT_EVENTS_TARGET 8 then you should be 128 * 8 events to re-evaluate. Huge pages can make the runaway much bigger but how it would be possible to runaway outside of that bound. Btw. do we really need SOFTLIMIT_EVENTS_TARGET at all? Why cannot we just stick with a single threshold? mem_cgroup_update_tree can be made a effectivelly a noop when there is no soft limit in place so overhead shouldn't matter for the vast majority of workloads. -- Michal Hocko SUSE Labs