Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp4534432pxb; Sat, 12 Feb 2022 08:21:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzS4dpVE8K0PAntZlkmU17ZeJ780z/JxnQs39pBs4lMhNIgTZT9TEzVkYcnwBhgP2ua4hwk X-Received: by 2002:a17:90b:3e8e:: with SMTP id rj14mr5870326pjb.112.1644682865581; Sat, 12 Feb 2022 08:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644682865; cv=none; d=google.com; s=arc-20160816; b=C1rWFS2jr5V6cPOF1j0DqOis/D1MfvCIFEEerjk+wLYZE9SzKT6ggLjcYFzO1SWEl9 y6zf/jtExYVJ3M8dl+TqWq4zXc0mo7daxJG0CJoZ2PWW98IWCZExF2QjhmbVXdYl8ddC HEVCi6QTipSbvbiZfZTHt+GLsxpmZf+jpHBaAMhvYUfKN9ml5wyOCxNi9j0BaFJueVVd VuMsLIV/MOxrvNyW0gEiyMpofNGmtWBtxaqYApRpXQp3LdNqp1SayBcTowzSZi9CQl9U axFomHSA4cec3BI55D2SJluMOGZL5twx0eKKTCrxO+XnyIEef6Nrahhzz01Q1CgtLHWL fnLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=CCAsjj+/2EPlyUQtiVo8WDkzcxXnQjrZ0PEqMW7wI0o=; b=ChmAf+ZW4Hh37AwnibJ3bNJP6erHr2TGr+ByAzFMMhZ3GImO6kiw5jmzg8bMT6xPrp 45YU57sPDTVnfQOKl+AEZIoeHZtPEq9IbQ//BaDle2l8F/eQyvOJ0/5ZRtlIIs4yWk0e hsbpiUenIEZIGIhj9j6pCjqGUwT5hza+vg78YNiXsLkLYH9xzTx5wTXYeUHTTeK+HyX/ WGejdTbRPZZjRzr86CRLiafQfiEUktdenxrVvXsi+8cwVf6lFOfjiCU1Jvskl9J8BCb5 a9qcjrLt6eIOSt6WAP0TMlYD/t5fhr0uqCc5VO8fiQtbR7+YyC0LD9IweJ67BcvpM8KR pWOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ppE7RooP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q205si24705798pgq.11.2022.02.12.08.20.50; Sat, 12 Feb 2022 08:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ppE7RooP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352677AbiBKUg4 (ORCPT + 93 others); Fri, 11 Feb 2022 15:36:56 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:36778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240394AbiBKUgy (ORCPT ); Fri, 11 Feb 2022 15:36:54 -0500 Received: from mail-lj1-x22e.google.com (mail-lj1-x22e.google.com [IPv6:2a00:1450:4864:20::22e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2FC5D57 for ; Fri, 11 Feb 2022 12:36:46 -0800 (PST) Received: by mail-lj1-x22e.google.com with SMTP id n24so11361630ljj.10 for ; Fri, 11 Feb 2022 12:36:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CCAsjj+/2EPlyUQtiVo8WDkzcxXnQjrZ0PEqMW7wI0o=; b=ppE7RooPi4WL00e0ZLJbFk100+IS02OV5QywrNLcKaCJbEtR4YxukPIudnLp8SeKMe 1NpTHSxW8chgPGf7JOY4Ea15KZrCmewdQuJqeHkqMC3F2oB8XRhcoJdjL6j9/F+7f8WJ uUAPTnA1DepzO0Qt+pe0IQN9d9vuPEWAghF7tyEwP6gcUibW6u7V60dsZ2Om7MgSwh3u hnqtLmgCUXP8KKVYUrxRFdwOov2m9joI3QdDjxk8pE/fUxhg1L3y/BZJCLku2CDajQza 5EbbCjrTyKK1IaSFwD9Kfjiz5aTiqTn7xQlm4sYnrDALmXTu3uE6ySHxWdrZ9XJkKkF2 1Hdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=CCAsjj+/2EPlyUQtiVo8WDkzcxXnQjrZ0PEqMW7wI0o=; b=6jDzjKnmklORNXu3p0AzAz4Ge88/Cc5FC2LeuSBKmZ8mOittddony+S9Mk/dV9u62Z 4b28BQweNOBL6I+cCXC76N8HXiFZZe5DeLMSgNA9Gw935hide8WRBnolSsOO4RbYjmz5 2v5+T/3svFv8jj3bGxRm6yD230Vja/UO5qJEATrUq8ovvk3mGPdkNG4U2Lg+ZyD3o4/9 iF0DGmREdvomqItcabmLPnBDUy94YoMvsx695efKdYIlRoj6K7Vvr4BjREvgzaZ84Uin q1/WNBefeoOoWQXQFtYuSGcMHnzwe8+ElUHwsO9iJpKycBGNC0G1aMqRdDvumOSmN9zY KFAA== X-Gm-Message-State: AOAM532qEBxCqpaB5R3mBCIvkdueV6zB1bDTLPy3WgwvH82qZiRUYLd4 8XMgWKACmbYT5iYPkgmW/j0A10tza5vhbtQffSxP0g== X-Received: by 2002:a2e:b16e:: with SMTP id a14mr1959958ljm.35.1644611804994; Fri, 11 Feb 2022 12:36:44 -0800 (PST) MIME-Version: 1.0 References: <20220211064917.2028469-1-shakeelb@google.com> <20220211064917.2028469-5-shakeelb@google.com> In-Reply-To: From: Shakeel Butt Date: Fri, 11 Feb 2022 12:36:33 -0800 Message-ID: Subject: Re: [PATCH v2 4/4] memcg: synchronously enforce memory.high for large overcharges To: Chris Down Cc: Johannes Weiner , Michal Hocko , Roman Gushchin , Andrew Morton , Cgroups , Linux MM , LKML Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 11, 2022 at 4:13 AM Chris Down wrote: > [...] > >To make high limit enforcement more robust, this patch makes the limit > >enforcement synchronous only if the accumulated overcharge becomes > >larger than MEMCG_CHARGE_BATCH. So, most of the allocations would still > >be throttled on the return-to-userspace path but only the extreme > >allocations which accumulates large amount of overcharge without > >returning to the userspace will be throttled synchronously. The value > >MEMCG_CHARGE_BATCH is a bit arbitrary but most of other places in the > >memcg codebase uses this constant therefore for now uses the same one. > > Note that mem_cgroup_handle_over_high() has its own allocator throttling grace > period, where it bails out if the penalty to apply is less than 10ms. The > reclaim will still happen, though. So throttling might not happen even for > roughly MEMCG_CHARGE_BATCH-sized allocations, depending on the overall size of > the cgroup and its protection. > Here by throttling, I meant both reclaim and schedule_timeout_killable(). I don't want to say low level details which might change in future. [...] > > Thanks, I was going to comment on v1 that I prefer to keep the implementation > of mem_cgroup_handle_over_high if possible since we know that the mechanism has > been safe in production over the past few years. > > One question I have is about throttling. It looks like this new > mem_cgroup_handle_over_high callsite may mean that throttling is invoked more > than once on a misbehaving workload that's failing to reclaim since the > throttling could be invoked both here and in return to userspace, right? That > might not be a problem, but we should think about the implications of that, > especially in relation to MEMCG_MAX_HIGH_DELAY_JIFFIES. > Please note that mem_cgroup_handle_over_high() clears memcg_nr_pages_over_high and if on the return-to-userspace path mem_cgroup_handle_over_high() finds that memcg_nr_pages_over_high is non-zero, then it means the task has further accumulated the charges over high limit after a possibly synchronous memcg_nr_pages_over_high() call. > Maybe we should record if throttling happened previously and avoid doing it > again for this entry into kernelspace? Not certain that's the right answer, but > we should think about what the new semantics should be. For now, I will keep this as is and will add a comment in the code and a mention in the commit message about it. I will wait for others to comment before sending the next version and thanks for taking a look.