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=-1.0 required=3.0 tests=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 DDCD6C433E0 for ; Fri, 15 May 2020 07:15:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A436020671 for ; Fri, 15 May 2020 07:15:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A436020671 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 406A290000C; Fri, 15 May 2020 03:15:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B77D8E0005; Fri, 15 May 2020 03:15:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A65890000C; Fri, 15 May 2020 03:15:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0113.hostedemail.com [216.40.44.113]) by kanga.kvack.org (Postfix) with ESMTP id 0E51E8E0005 for ; Fri, 15 May 2020 03:15:02 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id ACFA6181AEF0B for ; Fri, 15 May 2020 07:15:01 +0000 (UTC) X-FDA: 76818091602.03.verse60_832a69552ab02 X-HE-Tag: verse60_832a69552ab02 X-Filterd-Recvd-Size: 6103 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 May 2020 07:15:01 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id f134so1202936wmf.1 for ; Fri, 15 May 2020 00:15:01 -0700 (PDT) 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=wNnbDR/fnRC/T2e1j8iCp/maHR2CWtyzsflthlgO73c=; b=cTRi0z/hywqOPE6Sw6X5bRCZhVEvBGJvJQtraFs5mTERf+NiV5QCDW4L0+BSQCQnZl 1aw0KIvbruKsaGsusMAgipW7EYOmKe9fDoX+NRYCeNWlsWVD2UzizN9NZuOZIPXAFmg9 esNQoZvLW6Vg2cmFAmfN0dKsxU/NwzTOWEhbyi2DTKRNOIfTPbp8o9CUtXQoSzSoHM8Z lSIe2fp3WP927rAXRvcluPiIrgbevbloX1hZbBgRN8tyspZBGGB4cP2Bh8TeHjWTIBzg tngFzRolDzg30/LR5OvLV4YFt+8Yn/KTCENYzhrIkouD5SLh3VqWBXFQnEIS+Dq304Lg d0Kg== X-Gm-Message-State: AOAM532gy1PFGk8lDQpt8hD8Nq7mVBbAI0v3edfdf7a33TYp0HStVRJo VmP0vMKCWNMm2nRBNWVxnzo= X-Google-Smtp-Source: ABdhPJxOi6ZJ3DWHzJFEGKoPBDChDxIBiY+1Z+h895njnpdO+If8ji/zOjDRRm9zZ69E0ZSe2MWGGA== X-Received: by 2002:a05:600c:14c6:: with SMTP id i6mr2407088wmh.58.1589526900148; Fri, 15 May 2020 00:15:00 -0700 (PDT) Received: from localhost (ip-37-188-249-36.eurotel.cz. [37.188.249.36]) by smtp.gmail.com with ESMTPSA id t7sm2204827wrq.39.2020.05.15.00.14.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 May 2020 00:14:59 -0700 (PDT) Date: Fri, 15 May 2020 09:14:58 +0200 From: Michal Hocko To: Johannes Weiner Cc: Jakub Kicinski , 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 Subject: Re: [PATCH mm v2 3/3] mm: automatically penalize tasks with high swap use Message-ID: <20200515071458.GE29153@dhcp22.suse.cz> References: <20200511225516.2431921-1-kuba@kernel.org> <20200511225516.2431921-4-kuba@kernel.org> <20200512072634.GP29153@dhcp22.suse.cz> <20200512105536.748da94e@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20200513083249.GS29153@dhcp22.suse.cz> <20200513113623.0659e4c4@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com> <20200514074246.GZ29153@dhcp22.suse.cz> <20200514202130.GA591266@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200514202130.GA591266@cmpxchg.org> 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 Thu 14-05-20 16:21:30, Johannes Weiner wrote: > On Thu, May 14, 2020 at 09:42:46AM +0200, Michal Hocko wrote: > > On Wed 13-05-20 11:36:23, Jakub Kicinski wrote: > > > On Wed, 13 May 2020 10:32:49 +0200 Michal Hocko wrote: > > > > On Tue 12-05-20 10:55:36, Jakub Kicinski wrote: > > > > > On Tue, 12 May 2020 09:26:34 +0200 Michal Hocko wrote: > > > > > > On Mon 11-05-20 15:55:16, Jakub Kicinski wrote: > > > > > > > Use swap.high when deciding if swap is full. > > > > > > > > > > > > Please be more specific why. > > > > > > > > > > How about: > > > > > > > > > > Use swap.high when deciding if swap is full to influence ongoing > > > > > swap reclaim in a best effort manner. > > > > > > > > This is still way too vague. The crux is why should we treat hard and > > > > high swap limit the same for mem_cgroup_swap_full purpose. Please > > > > note that I am not saying this is wrong. I am asking for a more > > > > detailed explanation mostly because I would bet that somebody > > > > stumbles over this sooner or later. > > > > > > Stumbles in what way? > > > > Reading the code and trying to understand why this particular decision > > has been made. Because it might be surprising that the hard and high > > limits are treated same here. > > I don't quite understand the controversy. I do not think there is any controversy. All I am asking for is a clarification because this is non-intuitive. > 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. Thanks this is a useful summary. > That applies to physical swap limits, swap.max, and naturally also to > swap.high which is a limit to implement userspace OOM for swap space > exhaustion. > > > > Isn't it expected for the kernel to take reasonable precautions to > > > avoid hitting limits? > > > > Isn't the throttling itself the precautious? How does the swap cache > > and its control via mem_cgroup_swap_full interact here. See? This is > > what I am asking to have explained in the changelog. > > It sounds like we need better documentation of what vm_swap_full() and > friends are there for. It should have been obvious why swap.high - a > limit on available swap space - hooks into it. Agreed. The primary source for a confusion is the naming here. Because vm_swap_full doesn't really try to tell that the swap is full. It merely tries to tell that it is getting full and so duplicated data should be dropped. -- Michal Hocko SUSE Labs