Received: by 10.192.165.156 with SMTP id m28csp655649imm; Fri, 13 Apr 2018 05:46:55 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/Kxf6hB99soNLTP7st/HPiIqxk4LFgA/gHeKrugBixlQUJvpn5pC0xere3eO8J5KOQai8O X-Received: by 2002:a17:902:71cf:: with SMTP id t15-v6mr5134203plm.107.1523623615707; Fri, 13 Apr 2018 05:46:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523623615; cv=none; d=google.com; s=arc-20160816; b=MklaQmK9fTv9In+yt3tWxFonepxYeKubgQbbAIehkpjx9qDokUBRW5EQHeO9bYWG81 UcGpQUuq1qcxuuCrcuS9UVXoXl1sZ/pZpvt6LO/OeLtQBxlKf/Wz026LFjIgz+7p4Jji 7pEsfjB/swVj2DCrloAUjfweg6JhkCw2bRZB7cCLQ9mRQ/WPzUGnSAzgYUas0org1FPs 54uQFWrPw28TeFEaSK6jWJgahHoeANxgJp1h1t0GOMPXrwB3he5agieGlSLuTnhbgyi1 xvObzTP/8jO1lDEyXX6DcKPi5/8oamK+V+0sfgEGyvuIFxsQF+UImbMcB5Au2qSe3ZY1 KXkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=AQHCXMIsTSNHcc6o+sit2HuArSv+Fl1XJT4DjrH+t+g=; b=DxKrlWrE9O5I20LOiuFJ8TXZctOqDxfeUte/CYlkUqfA6vRfIz79S0rGtAGcmV1lzX C3GIk0j8xFdpDaayz97XOu9Qh5cf96gZ0JrV3iWTodeaTLVPGVzA0/pbT26qbaJF8+xD DmMYv9+Sp0U2mw9JozEXFJaRFrHSmdmU/a/Rj8sWMfgXinJAHAB6LySx/B7uEAYPQaIg ywtYMThX/fIZW0V2O/fxeiMENDQzwvBCmdd/NIYaY2YxU7qXsP3BL4Eb4sxaautSy+B1 OVODmANPhbLluVKr8ZitesbIi5Gb9K1n/IOqrDVkC4Jm/rZElB8tKdEl85m1Tb/z5M5B IRHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=uqa9u6ji; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l1-v6si5417938pld.312.2018.04.13.05.46.41; Fri, 13 Apr 2018 05:46:55 -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=@gmail.com header.s=20161025 header.b=uqa9u6ji; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754795AbeDMMNq (ORCPT + 99 others); Fri, 13 Apr 2018 08:13:46 -0400 Received: from mail-wm0-f49.google.com ([74.125.82.49]:52338 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753958AbeDMMNl (ORCPT ); Fri, 13 Apr 2018 08:13:41 -0400 Received: by mail-wm0-f49.google.com with SMTP id g8so4748657wmd.2; Fri, 13 Apr 2018 05:13:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AQHCXMIsTSNHcc6o+sit2HuArSv+Fl1XJT4DjrH+t+g=; b=uqa9u6jibw8Nscfj+MmKuOFeV5wKCRLIdVC4Z7fj4K8rk2GHlOcEm1uKdvKCSG8pTn bYJVH2cXSQ6Jal0fGR0aR0qjPR01dW5pHVp4/1BWyOFa6Fn1Ms/ERUgbeId8UlCfTHSW YxrpTHJvnc0o7knWD0Chzni3xhxMX+VUjv4uHwnTrnpOT58MTNWu4eoCw3PIGAQzGNnp umimwJryVkJSNAdwkTkYOtuosxJAA2BfuD5j7JpA4QKpQ5NLnq5QxFtVQSYcyf62PJnN 1GZHTzrztbQk1NBhVi/J32P7CS+NL7KoN8j3MbvVO+bmDxDdqCZgoW6js8bjw204VNtH 7zoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AQHCXMIsTSNHcc6o+sit2HuArSv+Fl1XJT4DjrH+t+g=; b=UuXz321Nm2BP106kB/P9PMS+Eq8IZwTKkOhI2k1+8fpP1qUioJnPce4Rm8yC0Lf/ea SYdvqvdPCC4uxfsR+IFMVFFLX897Ofzwucww/va90FzwEoMJL2zS2OEXgsdtJPNJxUKD tE4WdnpA0MFeHDMgmyE0NfLHcj1lbIIyAtYUvTSpa2gMl/+4iT+V6dEi7bSfxteQzZWv C1TrEyq6pJIYPoPkfDM9HpT3emyYfrN/4U6eRi+HoVnIV76ZIKSdQtNntt7GBRFLF0A1 FFgzAxDCqL2Y5mKCWP5Udvu+fS4RsqrZ6rOsClPRmu3aKN7JbKTtPvks6rdMCeTAqqXs 3KrQ== X-Gm-Message-State: ALQs6tDiImyZ7MIHOl5UFYs+1pPQu525PRuicAiKEqe+5ZOaRLLUV98I hHEGx0k0V4Z8yvKQBu3pI2kKZbvazX1L/oZYlTY= X-Received: by 10.28.132.7 with SMTP id g7mr3437828wmd.109.1523621620074; Fri, 13 Apr 2018 05:13:40 -0700 (PDT) MIME-Version: 1.0 Received: by 10.28.136.200 with HTTP; Fri, 13 Apr 2018 05:13:39 -0700 (PDT) In-Reply-To: <20180412145702.GB30714@castle.DHCP.thefacebook.com> 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: vinayak menon Date: Fri, 13 Apr 2018 17:43:39 +0530 Message-ID: Subject: Re: [PATCH 1/3] mm: introduce NR_INDIRECTLY_RECLAIMABLE_BYTES To: 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 Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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