Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2048761pxb; Mon, 23 Aug 2021 10:48:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZb8c/3FpivOY2UKQVKfMEjJgPEPhul5Izx1Zr65MdRFxwjzGRvO7G+VB4YSnpWuXfoz1g X-Received: by 2002:a02:7f48:: with SMTP id r69mr30539886jac.17.1629740900459; Mon, 23 Aug 2021 10:48:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629740900; cv=none; d=google.com; s=arc-20160816; b=qUfjQC0nlHnsuywDd5hdkWIGTjiycKkY/4z+wki66KeB0gGTs88iDtiDpKltvERicA scYZyOGEdnyvKVLMGxwzX8iEa0atbY9lTz9sp0TxnVIMtB6MrMyYJV9ZHeawiSkBQIaj Xnuqzo7gde54K08GEz2CM9Z73UfN1M9KEoFoV0/IzDNy3zE2CEPdyoa3TMyZFx8D4VrJ oD4N6UJsp8A1rNVOa0TuKk2PUDF9tZRhR6FP737psJS7m/hlNUdtDZOD1JSD8n7MWBeI P/OYXXQnggMFgyfJr3d6QDb1ARMrMcmyzuKzHVZGeo9mW8VcHu1zx+b1FsnYtYH5PaCp 6Rjg== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=gbkRpn8OvHDvVhkug5/SCecw4iR6zEDgQeKV01fnIoo=; b=N/mNuwQPPtIWmNA9bXEXa5Ejm5eFbjcHeYqWVHiKflSglm/CAj27zC1X2I/O+ub3yn +BD9VUH9SjWAjVcddDnMqoa60j6ANJkHNnEykunOW/Mm9vfFrVi/W1pBbU9X3xmgYzh8 GCZALLOsQflwKR4HXpQqJ2oIfR/6hqVcZWZtfnzbMfeNRetbzjGLap5dfcbdeT9sO6dO IR8r+MyP/U9DI0qSAbTtLdas+S7FiWzGDN4XZBXumziFDk8VK7jzsSvCMrfAIU9s9cDN 0BxtVybOG3N5GCEoDYus25oqxRYlddf0daw+ygG3xYKbXU7aSRTSyq9szQq/cErf8IlU zekw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=upkSxN2n; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c6si14535189jal.120.2021.08.23.10.48.08; Mon, 23 Aug 2021 10:48:20 -0700 (PDT) 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=@cmpxchg-org.20150623.gappssmtp.com header.s=20150623 header.b=upkSxN2n; 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=fail (p=NONE sp=NONE dis=NONE) header.from=cmpxchg.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231253AbhHWRrr (ORCPT + 99 others); Mon, 23 Aug 2021 13:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229889AbhHWRrq (ORCPT ); Mon, 23 Aug 2021 13:47:46 -0400 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [IPv6:2607:f8b0:4864:20::72e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84E0BC061575 for ; Mon, 23 Aug 2021 10:47:03 -0700 (PDT) Received: by mail-qk1-x72e.google.com with SMTP id m21so20039452qkm.13 for ; Mon, 23 Aug 2021 10:47:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cmpxchg-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=gbkRpn8OvHDvVhkug5/SCecw4iR6zEDgQeKV01fnIoo=; b=upkSxN2nnvY2Wv/MwUo3Qk+bN9RsxVHHPTcUHGhtMHImyRfryeKTsloFifEFrqdlt0 UxVtQai+tAQNcsIJ818me8Yhi3/bMHiaU7UglvqElSdxuOBTPg8BCOnN3T1AJfORwqcH NYTKsEACcfB06lkK8E4ps1ukwzCLeG8yfT85LndESHBE7pMmxUCgd78URSV2DpFKMKNs 5j1L94LSJYWhTz1Yyq8X6ZJU0F/PJxu6jlgN3V1E7rR727XeyxqXOvVGAY1aVcOmGrAW 7SpfwdKSRYCa67kYAD3SULGslNCC8EhJZcPuSsdvmwK1YPuq5Us1QyWndADVs8b5Lf83 KDZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=gbkRpn8OvHDvVhkug5/SCecw4iR6zEDgQeKV01fnIoo=; b=RZ9DASJohzyMK994CpUxmk3F/lhwyo8sxuquDIi/abPaRN6AHT2zInvfPvNFRaZJFc NiEq8XOKX2kbpBwR0mLrOBqYwJ3l/UllpVcO+oCYAwNqfKQBx+8fEoGCV5iLokCp/tZr RG9WLMHi36OmxDzwJtOZuRu5Z8eYnyP9a8Imhcof8aIXlb2oq9nYr9kxTtlh+gn67MMS SqmCl9OKWUu0q8CnlyM8gokFVbLQNMiM7O+47b5g7WojQhtS2sNWEMne4D3UEORYm0vS Yt7UisXPrEsliYCxc7TKdWU1fwYf2Ps8dcfuMreRLTshktrVaLhYQ4HZ+yV+Z612B8lI NCsw== X-Gm-Message-State: AOAM531D9TykoTCDwvcoyQUSn1YiF/HQAT6elbv1rxYB5kNYg75iwi3b Lrz92oHX+8r4RPZzwDCOH7GiLA== X-Received: by 2002:a05:620a:41:: with SMTP id t1mr17734902qkt.77.1629740822738; Mon, 23 Aug 2021 10:47:02 -0700 (PDT) Received: from localhost (cpe-98-15-154-102.hvc.res.rr.com. [98.15.154.102]) by smtp.gmail.com with ESMTPSA id s28sm8833950qkm.43.2021.08.23.10.47.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Aug 2021 10:47:01 -0700 (PDT) Date: Mon, 23 Aug 2021 13:48:43 -0400 From: Johannes Weiner To: Michal =?iso-8859-1?Q?Koutn=FD?= Cc: Andrew Morton , Leon Yang , Chris Down , Roman Gushchin , Michal Hocko , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] mm: memcontrol: fix occasional OOMs due to proportional memory.low reclaim Message-ID: References: <20210817180506.220056-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Michal, On Mon, Aug 23, 2021 at 06:09:29PM +0200, Michal Koutn? wrote: > Hello > > (and sorry for a belated reply). It's never too late, thanks for taking a look. > On Tue, Aug 17, 2021 at 02:05:06PM -0400, Johannes Weiner wrote: > > @@ -2576,6 +2578,15 @@ static void get_scan_count(struct lruvec *lruvec, struct scan_control *sc, > > [...] > > + /* memory.low scaling, make sure we retry before OOM */ > > + if (!sc->memcg_low_reclaim && low > min) { > > + protection = low; > > + sc->memcg_low_skipped = 1; > > IIUC, this won't result in memory.events:low increment although the > effect is similar (breaching (partial) memory.low protection) and signal > to the user is comparable (overcommited memory.low). Good observation. I think you're right, we should probably count such partial breaches as LOW events as well. Note that this isn't new behavior. My patch merely moved this part from mem_cgroup_protection(): - if (in_low_reclaim) - return READ_ONCE(memcg->memory.emin); Even before, if we retried due to just one (possibly insignificant) cgroup below low, we'd ignore proportional reclaim and partially breach ALL protected cgroups, while only counting a low event for the one group that is usage < low. > Admittedly, this patch's behavior adheres to the current documentation > (Documentation/admin-guide/cgroup-v2.rst): > > > The number of times the cgroup is reclaimed due to high memory > > pressure even though its usage is under the low boundary, > > however, that definition might not be what the useful indicator would > be now. > Is it worth including these partial breaches into memory.events:low? I think it is. How about: "The number of times the cgroup's memory.low-protected memory was reclaimed in order to avoid OOM during high memory pressure." And adding a MEMCG_LOW event to partial breaches. BTW, the comment block above this code is also out-of-date, because it says we're honoring memory.low on the retries, but that's not the case. I'll prepare a follow-up patch for these 3 things as well as the more verbose comment that Michal Hocko asked for on the retry logic.