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=-3.7 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED 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 86A6DC433DF for ; Wed, 27 May 2020 20:05:58 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49EA8208B8 for ; Wed, 27 May 2020 20:05:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cmpxchg-org.20150623.gappssmtp.com header.i=@cmpxchg-org.20150623.gappssmtp.com header.b="NTm+WSC8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49EA8208B8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=cmpxchg.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D7DCB8001A; Wed, 27 May 2020 16:05:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2DD380010; Wed, 27 May 2020 16:05:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C6B2B8001A; Wed, 27 May 2020 16:05:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0194.hostedemail.com [216.40.44.194]) by kanga.kvack.org (Postfix) with ESMTP id AADD080010 for ; Wed, 27 May 2020 16:05:57 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 713578245571 for ; Wed, 27 May 2020 20:05:57 +0000 (UTC) X-FDA: 76863579954.28.crime94_8b39d395bbd3d Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin28.hostedemail.com (Postfix) with ESMTP id 52D9EC8CC6 for ; Wed, 27 May 2020 20:05:57 +0000 (UTC) X-HE-Tag: crime94_8b39d395bbd3d X-Filterd-Recvd-Size: 5452 Received: from mail-qk1-f194.google.com (mail-qk1-f194.google.com [209.85.222.194]) by imf23.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 May 2020 20:05:56 +0000 (UTC) Received: by mail-qk1-f194.google.com with SMTP id w3so842407qkb.6 for ; Wed, 27 May 2020 13:05:56 -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:in-reply-to; bh=DWnL9S9WGTEGZuRBVdjP/jVDvy6htJ4NRm6fYZkzl3Y=; b=NTm+WSC85vpDh39BbXIYKURNZHjJKrwLhW+pSwDVbOMtLjTg+sROC2r1TgnVF1OQJT Z/+qWMAo9OaDwOtMZ35h9ZpEg8wgO3BAlWzDHpHSL5NVQUTCJ1bGJx6/6fy6SnXgg5Mm sRcUXPwwx6KDFyRWDqCOVko4xkFYLQeK0SUcGUMRAQwpQ8znovQguw8tU8jubSm8NX5k NN8fv1ZcfUBQ+ioRqagvGPVpPlH6peeyg50f2RCcHk36SNjEv1StDmpPr/igiJufMXgW r0OPMvAGHcAZuM+FcFT10yaa7c005AJgEA5QQNidQmLv5eEj1zntOfSGbVcYC3MSQDkq D0cQ== 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; bh=DWnL9S9WGTEGZuRBVdjP/jVDvy6htJ4NRm6fYZkzl3Y=; b=oaWxaQfz9tqBixUJtjgOkHIHMxVVAPeGJfApCVLXFKw0S5yu0QnPuXaVJ2cwH9rwcu xweNrv/4zG70nK3KmtLcX5aq6dvPFPSTGgliu/3YLKbYWCDYdigbTlbY7sbkPj7IGzE6 G7l3gL1wPlIzCc9txbc404fhVa53S54/Rn0sFQuTA16aMldW2F8T1IAH8oQ8yyrT7Bzq 2iwutwtOXOyC0BwvwBqdQvBt59PJQgSXFwQd8tUE9aEvMFaq9OhviYKKAHfdCnGW3TQT dJEG9UP0By5jBINl3VXYwMPHG9CUVcxbjgkDwU3rFAwDMt5o9q75qIcVO7AvVI0GA6xt chLQ== X-Gm-Message-State: AOAM532TOYS/V7ike3KhTEvlsV/53XUkQqsH4/b1labGnHNF9XMJcawC 2c2Wkam82PLBGDk9zwZ7LLdE3w== X-Google-Smtp-Source: ABdhPJyeQww6L2w9VuGgoNM/JrkQ+Pfmm5nu2uBvo3kyVTiYLPzYFVgO/6sMZP8jv39GOoqKsgyVoQ== X-Received: by 2002:a37:7906:: with SMTP id u6mr3071168qkc.495.1590609955949; Wed, 27 May 2020 13:05:55 -0700 (PDT) Received: from localhost ([2620:10d:c091:480::1:2535]) by smtp.gmail.com with ESMTPSA id x24sm3517886qth.57.2020.05.27.13.05.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 May 2020 13:05:55 -0700 (PDT) Date: Wed, 27 May 2020 16:05:30 -0400 From: Johannes Weiner To: Jakub Kicinski Cc: akpm@linux-foundation.org, linux-mm@kvack.org, kernel-team@fb.com, tj@kernel.org, chris@chrisdown.name, cgroups@vger.kernel.org, shakeelb@google.com, mhocko@kernel.org Subject: Re: [PATCH mm v6 4/4] mm: automatically penalize tasks with high swap use Message-ID: <20200527200530.GA49331@cmpxchg.org> References: <20200527195846.102707-1-kuba@kernel.org> <20200527195846.102707-5-kuba@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200527195846.102707-5-kuba@kernel.org> X-Rspamd-Queue-Id: 52D9EC8CC6 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam05 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: On Wed, May 27, 2020 at 12:58:46PM -0700, Jakub Kicinski wrote: > Add a memory.swap.high knob, which can be used to protect the system > from SWAP exhaustion. The mechanism used for penalizing is similar > to memory.high penalty (sleep on return to user space). > > That is not to say that the knob itself is equivalent to memory.high. > The objective is more to protect the system from potentially buggy > tasks consuming a lot of swap and impacting other tasks, or even > bringing the whole system to stand still with complete SWAP > exhaustion. Hopefully without the need to find per-task hard > limits. > > Slowing misbehaving tasks down gradually allows user space oom > killers or other protection mechanisms to react. oomd and earlyoom > already do killing based on swap exhaustion, and memory.swap.high > protection will help implement such userspace oom policies more > reliably. > > We can use one counter for number of pages allocated under > pressure to save struct task space and avoid two separate > hierarchy walks on the hot path. The exact overage is > calculated on return to user space, anyway. > > Take the new high limit into account when determining if swap > is "full". Borrowing the explanation from Johannes: > > The idea behind "swap full" is that as long as the workload has plenty > of swap space available and it's not changing its memory contents, it > makes sense to generously hold on to copies of data in the swap > device, even after the swapin. A later reclaim cycle can drop the page > without any IO. Trading disk space for IO. > > But the only two ways to reclaim a swap slot is when they're faulted > in and the references go away, or by scanning the virtual address space > like swapoff does - which is very expensive (one could argue it's too > expensive even for swapoff, it's often more practical to just reboot). > > So at some point in the fill level, we have to start freeing up swap > slots on fault/swapin. Otherwise we could eventually run out of swap > slots while they're filled with copies of data that is also in RAM. > > We don't want to OOM a workload because its available swap space is > filled with redundant cache. > > Signed-off-by: Jakub Kicinski This looks great to me now, thanks Jakub! Acked-by: Johannes Weiner