From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0330FC433E9 for ; Wed, 24 Feb 2021 11:56:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A81EC64EC3 for ; Wed, 24 Feb 2021 11:56:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235213AbhBXL4D (ORCPT ); Wed, 24 Feb 2021 06:56:03 -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