Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8282000ybi; Thu, 6 Jun 2019 09:32:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2/BOBIjc/XqGuXOIXVVXBJpne6xx/HXCLi9bMnD5ck7DCg+A5Np5OHhkmleGrJ/gO1CX/ X-Received: by 2002:a17:902:b083:: with SMTP id p3mr51229759plr.151.1559838763935; Thu, 06 Jun 2019 09:32:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559838763; cv=none; d=google.com; s=arc-20160816; b=GNv2E08Yqs6MBZ9xS12Sh5dfX5EXNbW1rM+Te3Bzcz0gaC8Ks3zX4obqdIS1Nggv+P JrTp1T5kvk93wUgBmpcZ8GN8GWxYThrMG3x+zA5Uzt7KfDWeBdXWaTcK5O837gyg36vu Yap0u18gby4p8JGkHxH2jfGnuqoWXctgKSvuHcLLGtyCq3AgxyvgPawnyYUVAn1uux8J sPiYoksMhI3HzklcBKy3pU2jhBvm6c7gpPPH8zNu4NXPjoxUqXU5Aq4pfMnS/vOfbnww RkD0xV2WLxRWXEZNoYD6ZTnE+qfIrOt66Jw3TFYzOzJNRSj410LMiVXEN7qGB4JZ6eNG wu1w== 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; bh=h8qEDdQVvgqhdDq9RUrIclI/RYacBNDWD7gszRkBp0o=; b=xkzNZe+jWUcT/X7+81rvcpNBTmlls5NhXOZ7r0jQWAukCd7RSutwy0QMX7uN9vPhwZ mu666qZkroRX6/ny/p+RTiPW4D8MrKNF6j4DcmnGoKJ2J2Zzjk7YxNqnA2+C5shasml7 OCO7MUzOy/hwxihSdLfMItqzvSoNJlEQajUEwDKayui8Mq8yiEt8rGvujOGsCvZKzs8a Yb5wCdA1A7pde4UnwTbbOZmwzNNnQl2qWDglK3J20lYsfo27BeTn9Mpq9SYcJtsGJcnI a6uTiLPmjk9JO3lgGf25q3C7sLtq0/ZI0ng7OEt6322vfcTNQgz+HCys3szblLPFe7kE berw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 187si2279647pfe.116.2019.06.06.09.32.26; Thu, 06 Jun 2019 09:32:43 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727973AbfFFLOy (ORCPT + 99 others); Thu, 6 Jun 2019 07:14:54 -0400 Received: from mx2.suse.de ([195.135.220.15]:36498 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726092AbfFFLOy (ORCPT ); Thu, 6 Jun 2019 07:14:54 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 0F722AE78; Thu, 6 Jun 2019 11:14:52 +0000 (UTC) Date: Thu, 6 Jun 2019 13:14:46 +0200 From: Michal Hocko To: Johannes Weiner Cc: Andrew Morton , linux-mm@kvack.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] mm: memcontrol: dump memory.stat during cgroup OOM Message-ID: <20190606111446.GA15779@dhcp22.suse.cz> References: <20190604210509.9744-1-hannes@cmpxchg.org> <20190605120837.GE15685@dhcp22.suse.cz> <20190605161133.GA12453@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190605161133.GA12453@cmpxchg.org> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed 05-06-19 12:11:33, Johannes Weiner wrote: > On Wed, Jun 05, 2019 at 02:08:37PM +0200, Michal Hocko wrote: [...] > > I am not entirely happy with that many lines in the oom report though. I > > do see that you are trying to reduce code duplication which is fine but > > would it be possible to squeeze all of these counters on a single line? > > The same way we do for the global OOM report? > > TBH I really hate those in the global reports because I always > struggle to find what I'm looking for. And smoking guns don't stand > out visually either. I'd rather have newlines there as well. This is obviously a matter of taste. I do not remember anybody complaining about the data density for the global oom reports. The amount of data is essentially the same so so there is no real technical argument one way or another. That being said, I still do not like the per line stats but I do not think this is a strong enough matter to argue about. The missing counters are interesting for oom reports analysis so the patch is an improvement. If you really do see it important then I will not stand in the way. One way or another feel free to add Acked-by: Michal Hocko > > > + seq_buf_init(&s, kvmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); > > > > What is the reason to use kvmalloc here? It doesn't make much sense to > > me to use it for the page size allocation TBH. > > Oh, good spot. I first did something similar to seq_file.c with an > auto-resizing buffer in case we print too much data. Then decided > that's silly since everything that will print into the buffer is right > there, and it's obvious that it'll fit, so I did the fixed allocation > and the WARN_ON instead. I've had a suspicion something like that happened. In any case using kvmalloc wouldn't be a bug. It would just be weird because we do not even fall back to vmalloc for this size IIRC. > > How about a simple kmalloc?. I know it's a page sized buffer, but the > gfp interface seems a bit too low-level and has weird kinks that > kmalloc nicely abstracts into a sane memory allocation interface, with > kmemleak support and so forth... Yeah, using kmalloc is fine. > Thanks for your review. > > Signed-off-by: Johannes Weiner > --- > > diff --git a/mm/memcontrol.c b/mm/memcontrol.c > index 0907a96ceddf..b0e0e840705d 100644 > --- a/mm/memcontrol.c > +++ b/mm/memcontrol.c > @@ -1371,7 +1371,7 @@ static char *memory_stat_format(struct mem_cgroup *memcg) > struct seq_buf s; > int i; > > - seq_buf_init(&s, kvmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); > + seq_buf_init(&s, kmalloc(PAGE_SIZE, GFP_KERNEL), PAGE_SIZE); > if (!s.buffer) > return NULL; > > @@ -1533,7 +1533,7 @@ void mem_cgroup_print_oom_meminfo(struct mem_cgroup *memcg) > if (!buf) > return; > pr_info("%s", buf); > - kvfree(buf); > + kfree(buf); > } > > /* > @@ -5775,7 +5775,7 @@ static int memory_stat_show(struct seq_file *m, void *v) > if (!buf) > return -ENOMEM; > seq_puts(m, buf); > - kvfree(buf); > + kfree(buf); > return 0; > } > -- Michal Hocko SUSE Labs