Received: by 10.192.165.148 with SMTP id m20csp214846imm; Tue, 24 Apr 2018 20:51:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/nHvhk7GglmWUsUmbO1u/dnUrIuORp2Kk5XZs2ajY4RKZU4yeQTL0I0jt8N0SeaDskDCpq X-Received: by 2002:a17:902:8e8a:: with SMTP id bg10-v6mr27916900plb.329.1524628261414; Tue, 24 Apr 2018 20:51:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524628261; cv=none; d=google.com; s=arc-20160816; b=fx7yK84hnfagF1CRoUtPvcxoIwHyb2QV7II/yjhN+8cNz8tcckHUD4BQqy8HAUttQi 2tVQtdG/0oEYsyEhTvDNzJMiV30vusIsl350jLtYzlR/SjWcCAC1M9BU2nHWmnwcU0q6 KmcrY9abSMQzuR8a9uplrzMwbVhGGgyE8QAj0EakecAOyBRYsENQ6EniWSoQNlLMkFGj uipACJOiXpbN+zj+lleqOL/1td/AGkW6pEBZG9+eN/gKplKCk8aBPlLXMxtQGbA33ojd bfxcQln+AwFNLpsZZU/CH6MMPswMTUruBp67ocpBwjgBPkPtQ5nyWV2dTdRI+kuEW9GY wuFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=l8RT2Y3WYZ9lESVgrHE9SqgaodZ4WHHz5S6uqMZ46hc=; b=V8WuGy69yoDu3jOLyEfEJ395jtBP9oRY2S7X5q47Zv5B7bRuZmE7EyedNZeP+HI07q A2NvAHSKBJb3AC/+oPfpkJFFAzxExVqKxT45a9YMQnMBsTLNcjs3UqmqEknV13x4biA9 oucpgrhckhJhNmXTRckXpQxw6uYx1H1apLjmphEP/o278jWo0XeE/GPlJCOn2UeIAtKm OAUOjxazNM3XzwXFMnAWCLZTFYQJPbf3OlfH9PJBXKlwR+88NlHp5bnntmia9TMQkUYZ 3yLPHDC1RohxTSxpGVV2tPM1rzOXBj2ibhNTzFw3w4ZE1BGmijp50lOfjjpCMxIl7zMS Cv9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Cb9WcFbn; dkim=pass header.i=@codeaurora.org header.s=default header.b=kJIE/m5K; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u21si14837622pfl.143.2018.04.24.20.50.46; Tue, 24 Apr 2018 20:51:01 -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=@codeaurora.org header.s=default header.b=Cb9WcFbn; dkim=pass header.i=@codeaurora.org header.s=default header.b=kJIE/m5K; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbeDYDtn (ORCPT + 99 others); Tue, 24 Apr 2018 23:49:43 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44208 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161AbeDYDtj (ORCPT ); Tue, 24 Apr 2018 23:49:39 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 42C516090E; Wed, 25 Apr 2018 03:49:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524628179; bh=zDHK0vs3UUoNQ4A//hIRXkmHgGpn7EpgMT9N7Yxhh7I=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Cb9WcFbnZY2yaE1XcLrYD0tX2CcrNbF4ADAnfhIY8yXMsdd6n21YsGucYjBmaPE8A +O9DDqEP3y3FhRAGlO83N+xGE3ay+4/xIpHmrBCee9i9Y+bDvVO9DpXSjIsICSBa3u SNheKsS9hxj+YZc49XtVZjVyNj38eMigbDA6+wO0= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.204.79.71] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vjitta@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id B0E88601CF; Wed, 25 Apr 2018 03:49:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1524628174; bh=zDHK0vs3UUoNQ4A//hIRXkmHgGpn7EpgMT9N7Yxhh7I=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=kJIE/m5KKrKdx4qyNDR9nZZAAFl6FL1a15Ty1qDeZzVtZXKmMCPFVcOFv3JIMPbMg UP6vyd6aZe4ynOW4fOEIrO2iG1DIU6O8FI9BKbG6gmLs6hhZ6FprgKF3fXUoWfCCxB qXJQotuRPejTEFNIkm2NhP489fUaC4WYXntNYxuM= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org B0E88601CF Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vjitta@codeaurora.org Subject: Re: [PATCH 1/3] mm: introduce NR_INDIRECTLY_RECLAIMABLE_BYTES To: vinayak menon , Roman Gushchin Cc: Vlastimil Babka , linux-mm@kvack.org, Andrew Morton , Alexander Viro , Michal Hocko , Johannes Weiner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Linux API References: <20180305133743.12746-1-guro@fb.com> <20180305133743.12746-2-guro@fb.com> <08524819-14ef-81d0-fa90-d7af13c6b9d5@suse.cz> <20180411135624.GA24260@castle.DHCP.thefacebook.com> <46dbe2a5-e65f-8b72-f835-0210bc445e52@suse.cz> <20180412145702.GB30714@castle.DHCP.thefacebook.com> From: Vijayanand Jitta Message-ID: <69b4dcd8-1925-e0e8-d9b4-776f3405b769@codeaurora.org> Date: Wed, 25 Apr 2018 09:19:29 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/13/2018 5:43 PM, vinayak menon wrote: > On Thu, Apr 12, 2018 at 8:27 PM, Roman Gushchin wrote: >> On Thu, Apr 12, 2018 at 08:52:52AM +0200, Vlastimil Babka wrote: >>> On 04/11/2018 03:56 PM, Roman Gushchin wrote: >>>> On Wed, Apr 11, 2018 at 03:16:08PM +0200, Vlastimil Babka wrote: >>>>> [+CC linux-api] >>>>> >>>>> On 03/05/2018 02:37 PM, Roman Gushchin wrote: >>>>>> This patch introduces a concept of indirectly reclaimable memory >>>>>> and adds the corresponding memory counter and /proc/vmstat item. >>>>>> >>>>>> Indirectly reclaimable memory is any sort of memory, used by >>>>>> the kernel (except of reclaimable slabs), which is actually >>>>>> reclaimable, i.e. will be released under memory pressure. >>>>>> >>>>>> The counter is in bytes, as it's not always possible to >>>>>> count such objects in pages. The name contains BYTES >>>>>> by analogy to NR_KERNEL_STACK_KB. >>>>>> >>>>>> Signed-off-by: Roman Gushchin >>>>>> Cc: Andrew Morton >>>>>> Cc: Alexander Viro >>>>>> Cc: Michal Hocko >>>>>> Cc: Johannes Weiner >>>>>> Cc: linux-fsdevel@vger.kernel.org >>>>>> Cc: linux-kernel@vger.kernel.org >>>>>> Cc: linux-mm@kvack.org >>>>>> Cc: kernel-team@fb.com >>>>> >>>>> Hmm, looks like I'm late and this user-visible API change was just >>>>> merged. But it's for rc1, so we can still change it, hopefully? >>>>> >>>>> One problem I see with the counter is that it's in bytes, but among >>>>> counters that use pages, and the name doesn't indicate it. >>>> >>>> Here I just followed "nr_kernel_stack" path, which is measured in kB, >>>> but this is not mentioned in the field name. >>> >>> Oh, didn't know. Bad example to follow :P >>> >>>>> Then, I don't >>>>> see why users should care about the "indirectly" part, as that's just an >>>>> implementation detail. It is reclaimable and that's what matters, right? >>>>> (I also wanted to complain about lack of Documentation/... update, but >>>>> looks like there's no general file about vmstat, ugh) >>>> >>>> I agree, that it's a bit weird, and it's probably better to not expose >>>> it at all; but this is how all vm counters work. We do expose them all >>>> in /proc/vmstat. A good number of them is useless until you are not a >>>> mm developer, so it's arguable more "debug info" rather than "api". >>> >>> Yeah the problem is that once tools start rely on them, they fall under >>> the "do not break userspace" rule, however we call them. So being >>> cautious and conservative can't hurt. >>> >>>> It's definitely not a reason to make them messy. >>>> Does "nr_indirectly_reclaimable_bytes" look better to you? >>> >>> It still has has the "indirecly" part and feels arbitrary :/ >>> >>>>> >>>>> I also kind of liked the idea from v1 rfc posting that there would be a >>>>> separate set of reclaimable kmalloc-X caches for these kind of >>>>> allocations. Besides accounting, it should also help reduce memory >>>>> fragmentation. The right variant of cache would be detected via >>>>> __GFP_RECLAIMABLE. >>>> >>>> Well, the downside is that we have to introduce X new caches >>>> just for this particular problem. I'm not strictly against the idea, >>>> but not convinced that it's much better. >>> >>> Maybe we can find more cases that would benefit from it. Heck, even slab >>> itself allocates some management structures from the generic kmalloc >>> caches, and if they are used for reclaimable caches, they could be >>> tracked as reclaimable as well. >> >> This is a good catch! >> >>> >>>>> >>>>> With that in mind, can we at least for now put the (manually maintained) >>>>> byte counter in a variable that's not directly exposed via /proc/vmstat, >>>>> and then when printing nr_slab_reclaimable, simply add the value >>>>> (divided by PAGE_SIZE), and when printing nr_slab_unreclaimable, >>>>> subtract the same value. This way we would be simply making the existing >>>>> counters more precise, in line with their semantics. >>>> >>>> Idk, I don't like the idea of adding a counter outside of the vm counters >>>> infrastructure, and I definitely wouldn't touch the exposed >>>> nr_slab_reclaimable and nr_slab_unreclaimable fields. >>> >>> We would be just making the reported values more precise wrt reality. >> >> It depends on if we believe that only slab memory can be reclaimable >> or not. If yes, this is true, otherwise not. >> >> My guess is that some drivers (e.g. networking) might have buffers, >> which are reclaimable under mempressure, and are allocated using >> the page allocator. But I have to look closer... >> > > One such case I have encountered is that of the ION page pool. The page pool > registers a shrinker. When not in any memory pressure page pool can go high > and thus cause an mmap to fail when OVERCOMMIT_GUESS is set. I can send > a patch to account ION page pool pages in NR_INDIRECTLY_RECLAIMABLE_BYTES. > > Thanks, > Vinayak > As Vinayak mentioned NR_INDIRECTLY_RECLAIMABLE_BYTES can be used to solve the issue with ION page pool when OVERCOMMIT_GUESS is set, the patch for the same can be found here https://lkml.org/lkml/2018/4/24/1288