Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1098811img; Fri, 22 Mar 2019 15:50:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjqWwTYCJTDlAc3a56cvLEjH2Jog85rNLARwRlFo4aieoxdL0i44fQ/2j5Vg3XxEMZYPex X-Received: by 2002:a17:902:523:: with SMTP id 32mr11757922plf.249.1553295054119; Fri, 22 Mar 2019 15:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553295054; cv=none; d=google.com; s=arc-20160816; b=WhNMgtxT9agzjRxav4qhLH2LsEz9CxgufCVAAPCZqkO9x8h6mcusc1Dxc+qXSubpaw mmd+uTdx78+9eCoQz/Zs/ByTz0qjPTfqI+VqwPxna01/7ZgFZKmm125tOfa+oqabq3du A+d6EJSSCtycgwSC10DeMuAD0IpHjZbKwMFdaERKaCbieYtRn8fLqp8UyFxzXf0Hbb6o CDArzSp2Nc3jCHXG1PTGSJztFRRAHR2YIet/pWx1fTWpSxRtXRkFwFZCPYxPrs3atI1H /PY995aWhhzqlPs/l87vErAMgw+liLn7cexUrEi62dxoCa4egWVZ8FKO/bc7Te6xhrhi fvtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Y9aDRaeIImkqbs3RD6gMjzp9RFeZ93eNkXfZogPMzV4=; b=keGWhSv6H4VozKom4JEt4npySLUaGy3XWnDHFU3skUHu6LF1UvxilvIFxYW4O55lQT mKw9Okjs93ahgj25l76eEfnG1pTsB8AVH8XudqlvyDcqEj4M92ce59O4q/LdmMFJ9SMP 1lKFEI6Jt+NpYUnz6ZsbU1ZJMNn+Y5OrPlfzP+HW1xDgpYRvvLGGYETTiz3JxcStAspo dMYxNmPHZjNLjEl88GpQVJCUHlBW0deEMzs4kKEm3XR5NMtYB6eA871KNTUZcLPocBJ0 wzOKHzUOSV1oiET+O4fe5OwW+JNJk4hoAzUzwIyH0lJHSasowXxx6lZrBNXykpzSn9dj qVDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=dzOycvFR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t18si8074346plr.78.2019.03.22.15.50.39; Fri, 22 Mar 2019 15:50:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=dzOycvFR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chrisdown.name Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728338AbfCVWtv (ORCPT + 99 others); Fri, 22 Mar 2019 18:49:51 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:36842 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727918AbfCVWtt (ORCPT ); Fri, 22 Mar 2019 18:49:49 -0400 Received: by mail-wm1-f67.google.com with SMTP id h18so3626860wml.1 for ; Fri, 22 Mar 2019 15:49:48 -0700 (PDT) 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=Y9aDRaeIImkqbs3RD6gMjzp9RFeZ93eNkXfZogPMzV4=; b=dzOycvFR3LXcdAJzc1cZuTdB5YuJ4celv5OXmLq76bC6fhuIRBXXymUZ2X1e4X3GPz g+RHtQxVTPHKrMHRvLhSlNJtytCLr+c/sSTjz6Ejtz9K6fAOuiJqD90x+aTB17NOUbU2 C2jzjifh8zT6akDauo5+bFHj33WXlPFIZB7+0= 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=Y9aDRaeIImkqbs3RD6gMjzp9RFeZ93eNkXfZogPMzV4=; b=t4pNThUn0jwDN8OMGttHLF6aDFH0eOlpK2vr+U+4bOpgMfc1NKkfQqV7+YJhtIxKAv JQgyWAlQG3391QNqkkMNpPKR2WMrRtbbVX7njYE9+xOSAGcvuyE3B3q+pbRXDk533IrJ MEwJE8tQWz2wdMa8aD0VaMY6wsdyaVpE/I/g1s8zhHuqz36YvSjvWUylqP0dDq32gNkm GsYP7IT3xjIYWo0u8y5/mGjZXXTrDNK6V2PJAqRXKkq/JDuFQksyLExVu3lXNQkqKwhx dijNjjUrkIkYPFtLRgkLW+iz9fIZqJfWrh4rDMSPrNfLQpdyZsE/M1aOWQdIbHxWj5Hx 2Lig== X-Gm-Message-State: APjAAAVy2rMZ8EjwpIyNMttcLcferBi18M51scrIvpcO2zevOqLMgw6f skV26QSLE5yk7HIVvnaGy3J0rg== X-Received: by 2002:a1c:ac87:: with SMTP id v129mr4695169wme.72.1553294987958; Fri, 22 Mar 2019 15:49:47 -0700 (PDT) Received: from localhost ([89.36.66.5]) by smtp.gmail.com with ESMTPSA id u12sm9138257wrt.2.2019.03.22.15.49.47 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Fri, 22 Mar 2019 15:49:47 -0700 (PDT) Date: Fri, 22 Mar 2019 22:49:46 +0000 From: Chris Down To: Roman Gushchin Cc: Andrew Morton , Johannes Weiner , Michal Hocko , Tejun Heo , Dennis Zhou , "linux-kernel@vger.kernel.org" , "cgroups@vger.kernel.org" , "linux-mm@kvack.org" , Kernel Team Subject: Re: [PATCH REBASED] mm, memcg: Make scan aggression always exclude protection Message-ID: <20190322224946.GA12527@chrisdown.name> References: <20190228213050.GA28211@chrisdown.name> <20190322160307.GA3316@chrisdown.name> <20190322222907.GA17496@tower.DHCP.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20190322222907.GA17496@tower.DHCP.thefacebook.com> User-Agent: Mutt/1.11.4 (2019-03-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Roman Gushchin writes: >I've noticed that the old version is just wrong: if cgroup_size is way smaller >than max(min, low), scan will be set to -lruvec_size. >Given that it's unsigned long, we'll end up with scanning the whole list >(due to clamp() below). Are you certain? If so, I don't see what you mean. This is how the code looks in Linus' tree after the fixups: unsigned long cgroup_size = mem_cgroup_size(memcg); unsigned long baseline = 0; if (!sc->memcg_low_reclaim) baseline = lruvec_size; scan = lruvec_size * cgroup_size / protection - baseline; This works correctly as far as I can tell: low reclaim case: In [1]: cgroup_size=50; lruvec_size=10; protection=2000; baseline=0; lruvec_size * cgroup_size // protection - baseline Out[1]: 0 normal case: In [2]: cgroup_size=3000; lruvec_size=10; protection=2000; baseline=lruvec_size; lruvec_size * cgroup_size // protection - baseline Out[2]: 5