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=-12.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 7CBD8C433DB for ; Mon, 25 Jan 2021 14:00:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EE334230FD for ; Mon, 25 Jan 2021 14:00:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EE334230FD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chrisdown.name Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2ABAE8D0003; Mon, 25 Jan 2021 09:00:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 25C1E8D0001; Mon, 25 Jan 2021 09:00:30 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 180698D0003; Mon, 25 Jan 2021 09:00:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0079.hostedemail.com [216.40.44.79]) by kanga.kvack.org (Postfix) with ESMTP id 025B28D0001 for ; Mon, 25 Jan 2021 09:00:29 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id AD62C180AE800 for ; Mon, 25 Jan 2021 14:00:29 +0000 (UTC) X-FDA: 77744457378.18.sink70_590c50627586 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id 1B168100ED0F9 for ; Mon, 25 Jan 2021 14:00:17 +0000 (UTC) X-HE-Tag: sink70_590c50627586 X-Filterd-Recvd-Size: 6130 Received: from mail-ej1-f51.google.com (mail-ej1-f51.google.com [209.85.218.51]) by imf27.hostedemail.com (Postfix) with ESMTP for ; Mon, 25 Jan 2021 14:00:16 +0000 (UTC) Received: by mail-ej1-f51.google.com with SMTP id r12so18105012ejb.9 for ; Mon, 25 Jan 2021 06:00:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=yqpENXleq5E1oCuiN5/o6zE4Va7QALVP2kUA8G3qGGs=; b=dq0PShZkY/NDrKnXPhmakBasO0lwF5zkAQmQUHQHZngpAlpDaW0QCKaMHWfS1x2MRX H6yEigZl3XM4wEp3GiUUHQsHG25OgCInjSJ92R+u637SREnILArI5W65YQxMgA2cuR0z ngGRnz7cdegpqGNe7XrbaPCunkM70lrkv4NKw= 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:in-reply-to:user-agent; bh=yqpENXleq5E1oCuiN5/o6zE4Va7QALVP2kUA8G3qGGs=; b=Ehi48MIE2uzQnfuL7hl0075HvfIMofWT2T96CqfuuF7NKyqV9lxh9VraC0v+u2kc5m DKW3lBCa2rTSuEyjCITrMKPTbfnnkHak74tLmdF4Xep7TL9+vSBw0tyJr6jIofmS6IQ9 eFM52vw7QekL0iPiz6vXrZeCtlbloZ90Dw6108tzUtWgtLmrEGWoVv1n323w3eV1Omvw XdcUWnEz0P1evUWlwC7IWd2IkaPQfTVVqwv8vx06AgtUmAP2NkoJF5JqUYs1PiMuXQA0 LfE9MJQVmRU/mSzmjyPeFS2lgN7QCv0TsDzYAXoenjBJr9cRlQZgLvOzRzQgJ2kDjd4x F1qA== X-Gm-Message-State: AOAM533cSsHhihTYgAi7M3jUsmlHFsve9/DEbV4NI6Abl0SpoPInem0X SWePEKxRMcA3h+yuaFupocxtxw== X-Google-Smtp-Source: ABdhPJzZES+L+Kd3IwNeDiMVM0jatuI5AjktdSrGuf4mIqLTdLqC8vouza1440lnY8wsSOCuaxVo1Q== X-Received: by 2002:a17:906:af41:: with SMTP id ly1mr411223ejb.491.1611583215092; Mon, 25 Jan 2021 06:00:15 -0800 (PST) Received: from localhost ([2620:10d:c093:400::4:36f8]) by smtp.gmail.com with ESMTPSA id m5sm8346994eja.11.2021.01.25.06.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jan 2021 06:00:14 -0800 (PST) Date: Mon, 25 Jan 2021 14:00:14 +0000 From: Chris Down To: Johannes Weiner Cc: Andrew Morton , Roman Gushchin , Michal Hocko , Shakeel Butt , Michal =?iso-8859-1?Q?Koutn=FD?= , Tejun Heo , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] Revert "mm: memcontrol: avoid workload stalls when lowering memory.high" Message-ID: References: <20210122184341.292461-1-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210122184341.292461-1-hannes@cmpxchg.org> User-Agent: Mutt/2.0.4 (26f41dd1) (2020-12-30) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Johannes Weiner writes: >This reverts commit 536d3bf261a2fc3b05b3e91e7eef7383443015cf, as it >can cause writers to memory.high to get stuck in the kernel forever, >performing page reclaim and consuming excessive amounts of CPU cycles. > >Before the patch, a write to memory.high would first put the new limit >in place for the workload, and then reclaim the requested delta. After >the patch, the kernel tries to reclaim the delta before putting the >new limit into place, in order to not overwhelm the workload with a >sudden, large excess over the limit. However, if reclaim is actively >racing with new allocations from the uncurbed workload, it can keep >the write() working inside the kernel indefinitely. > >This is causing problems in Facebook production. A privileged >system-level daemon that adjusts memory.high for various workloads >running on a host can get unexpectedly stuck in the kernel and >essentially turn into a sort of involuntary kswapd for one of the >workloads. We've observed that daemon busy-spin in a write() for >minutes at a time, neglecting its other duties on the system, and >expending privileged system resources on behalf of a workload. > >To remedy this, we have first considered changing the reclaim logic to >break out after a couple of loops - whether the workload has converged >to the new limit or not - and bound the write() call this way. >However, the root cause that inspired the sequence change in the first >place has been fixed through other means, and so a revert back to the >proven limit-setting sequence, also used by memory.max, is preferable. > >The sequence was changed to avoid extreme latencies in the workload >when the limit was lowered: the sudden, large excess created by the >limit lowering would erroneously trigger the penalty sleeping code >that is meant to throttle excessive growth from below. Allocating >threads could end up sleeping long after the write() had already >reclaimed the delta for which they were being punished. > >However, erroneous throttling also caused problems in other scenarios >at around the same time. This resulted in commit b3ff92916af3 ("mm, >memcg: reclaim more aggressively before high allocator throttling"), >included in the same release as the offending commit. When allocating >threads now encounter large excess caused by a racing write() to >memory.high, instead of entering punitive sleeps, they will simply be >tasked with helping reclaim down the excess, and will be held no >longer than it takes to accomplish that. This is in line with regular >limit enforcement - i.e. if the workload allocates up against or over >an otherwise unchanged limit from below. > >With the patch breaking userspace, and the root cause addressed by >other means already, revert it again. > >Fixes: 536d3bf261a2 ("mm: memcontrol: avoid workload stalls when lowering memory.high") >Cc: # 5.8+ >Reported-by: Tejun Heo >Signed-off-by: Johannes Weiner Acked-by: Chris Down