From patchwork Fri Nov 2 13:31:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tetsuo Handa X-Patchwork-Id: 10665553 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5D40413BF for ; Fri, 2 Nov 2018 13:33:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 42FC52B13F for ; Fri, 2 Nov 2018 13:33:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 324272B5E2; Fri, 2 Nov 2018 13:33:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB4F62B13F for ; Fri, 2 Nov 2018 13:33:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A640E6B000A; Fri, 2 Nov 2018 09:33:03 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A39FC6B000C; Fri, 2 Nov 2018 09:33:03 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8DDE16B000D; Fri, 2 Nov 2018 09:33:03 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-it1-f198.google.com (mail-it1-f198.google.com [209.85.166.198]) by kanga.kvack.org (Postfix) with ESMTP id 617876B000A for ; Fri, 2 Nov 2018 09:33:03 -0400 (EDT) Received: by mail-it1-f198.google.com with SMTP id r188-v6so2712892itb.9 for ; Fri, 02 Nov 2018 06:33:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references; bh=zlWDkH1QLH3IS0eoY7xZLzfAZz+aBiZOT6F68LgB42U=; b=Fi7246J+2HxsOV/qtjFwn5GO8VwxWwZumNmw8w1IzLeugRgNmZOPHwOy/JPwbcfiUc KrRkN5qTU4A2KMTY3tTWDaTdN4NkPfT/QM8PJTSh1vWkjANpyuqs0dJESQLXQ/RtLgVY IJhFPeW/6FnI8hv/WaVKe5o1nInNi9AYGm3xYOn6peeq/5LNqisrbnFKjfLDlCSX+2w0 RdqCyIEic65xUQtzIc98NmiKU1lgkUUgk4FMLXUFiQH7UCJpQCQ8mcgaANKt6DmDVINU kS9JDvM8jQcxNyOMnnwguWiZdi6tRnBYPwybnMYoXCD+jv4uWtxGSI+oEmKhbks5+7xR glPg== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp X-Gm-Message-State: AGRZ1gLgAG9TmMxhzUDkwyZb/9Lcb8PyiF1N5lr/1zOxB2yBy+KwRHp8 y/8WAdlYdQtMc0ChZE2IWs5vAO8wlRuUxCdLWwDzM1nXdiGaSq9PczAJxTSOe2LbXY8jP1+MJ/v nRKLdu6G1vmE4hKNIn7h3aajZEVqFmgzB5Ywv27GaBJHL/4iKuFqtpKWvdnXGshdKIg== X-Received: by 2002:a24:d4c1:: with SMTP id x184-v6mr733810itg.79.1541165583076; Fri, 02 Nov 2018 06:33:03 -0700 (PDT) X-Google-Smtp-Source: AJdET5d+w8xfYQGP6FLDndxpyPIbf+A4TBTUg2NCy9sk4CXw98klrs+7pbnNJL7Gjkayzm0ZGHtQ X-Received: by 2002:a24:d4c1:: with SMTP id x184-v6mr733701itg.79.1541165581624; Fri, 02 Nov 2018 06:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1541165581; cv=none; d=google.com; s=arc-20160816; b=zC7F82IxhWeM/hqWCWb25oORiDWWGWOjItHn31DhQF7gMqdn5cD6/j7Psn8fZCa5t4 I1hPcVaXK3cfsuICJ1eUiqbsc5P3iDjG7+BhuRRevioOhzcwfNVsdQTHccvOSDF1Y6u7 P8QX5WM5DrISqPYnThXltmJMs7nsoUlC0J+fnqng3tyH95hkPQdx9s6FYvBHCWPRKQrG jwRL8htlFTpTV4voZ3b1Qj+zRkQ40rGp4FhUJRlQD+H0jms8rBRxudcETybHQYIdH3KO 1RM2qFQPJgwDXqt4V33oqMu33/BB56onD1dxYNVAZVaP3gZDR85TT2QsoYXmgrQ8LYGl jDpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from; bh=zlWDkH1QLH3IS0eoY7xZLzfAZz+aBiZOT6F68LgB42U=; b=XrcYiPwTMwABhlK/lmC5Z9hIwdShCtQ0FZ+STEAvlR7e0XMYatzsnXaYXQR5UC0bQs 2Kvku9J07qiKMDtZtJX4PDmwaWgHjwy4kOhd0o11dl2pfnZtUQM03+SvbunUxTRsE/2n FMuSDAA+TbJhjvc4YDxmSYwHya0v5z1wm3mV8k4BfIPI0LfdPspqD87Jt8y4fcdqkHJs BLd0FANCYyKmPy3d6XE8fjci9Ksnx67GnuoONpUa7EqPAKHqYNOVs2EBFfFcn+ScapKT d1Y3kMDE6BQa52xYw8Ll7gD0wRLMZmwIDBIecB+qQ7dqUN28E66iB48Am5DfEmcwp0Jy C0pw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from www262.sakura.ne.jp (www262.sakura.ne.jp. [202.181.97.72]) by mx.google.com with ESMTPS id q6si19290540itj.38.2018.11.02.06.33.00 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Nov 2018 06:33:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) client-ip=202.181.97.72; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of penguin-kernel@i-love.sakura.ne.jp designates 202.181.97.72 as permitted sender) smtp.mailfrom=penguin-kernel@i-love.sakura.ne.jp Received: from fsav105.sakura.ne.jp (fsav105.sakura.ne.jp [27.133.134.232]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id wA2DWAYE084888; Fri, 2 Nov 2018 22:32:10 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav105.sakura.ne.jp (F-Secure/fsigk_smtp/530/fsav105.sakura.ne.jp); Fri, 02 Nov 2018 22:32:10 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/530/fsav105.sakura.ne.jp) Received: from ccsecurity.localdomain (softbank060157065137.bbtec.net [60.157.65.137]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id wA2DW4kM084867 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 2 Nov 2018 22:32:09 +0900 (JST) (envelope-from penguin-kernel@I-love.SAKURA.ne.jp) From: Tetsuo Handa To: Petr Mladek , Sergey Senozhatsky , Sergey Senozhatsky , Dmitriy Vyukov , Steven Rostedt Cc: Alexander Potapenko , Fengguang Wu , Josh Poimboeuf , LKML , Linus Torvalds , Andrew Morton , linux-mm@kvack.org, Ingo Molnar , Peter Zijlstra , Will Deacon , Tetsuo Handa Subject: [PATCH 2/3] mm: Use line-buffered printk() for show_free_areas(). Date: Fri, 2 Nov 2018 22:31:56 +0900 Message-Id: <1541165517-3557-2-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1541165517-3557-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> References: <1541165517-3557-1-git-send-email-penguin-kernel@I-love.SAKURA.ne.jp> 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: X-Virus-Scanned: ClamAV using ClamSMTP syzbot is sometimes getting mixed output like below due to concurrent printk(). Mitigate such output by using line-buffered printk() API. Node 0 DMA: 1*4kB (U) 0*8kB 0*16kB 1*32kB syz-executor0: page allocation failure: order:0, mode:0x484020(GFP_ATOMIC|__GFP_COMP), nodemask=(null) (U) syz-executor0 cpuset= 2*64kB syz0 (U) mems_allowed=0 1*128kB CPU: 0 PID: 7592 Comm: syz-executor0 Not tainted 4.19.0-rc6+ #118 (U) Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 1*256kB (U) Call Trace: 0*512kB 1*1024kB __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x1c4/0x2b4 lib/dump_stack.c:113 (U) 1*2048kB warn_alloc.cold.119+0xb7/0x1bd mm/page_alloc.c:3426 (M) Signed-off-by: Tetsuo Handa Cc: Andrew Morton --- mm/page_alloc.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index a919ba5..4411d5a 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -4694,10 +4694,10 @@ unsigned long nr_free_pagecache_pages(void) return nr_free_zone_pages(gfp_zone(GFP_HIGHUSER_MOVABLE)); } -static inline void show_node(struct zone *zone) +static inline void show_node(struct zone *zone, struct printk_buffer *buf) { if (IS_ENABLED(CONFIG_NUMA)) - printk("Node %d ", zone_to_nid(zone)); + printk_buffered(buf, "Node %d ", zone_to_nid(zone)); } long si_mem_available(void) @@ -4814,7 +4814,7 @@ static bool show_mem_node_skip(unsigned int flags, int nid, nodemask_t *nodemask #define K(x) ((x) << (PAGE_SHIFT-10)) -static void show_migration_types(unsigned char type) +static void show_migration_types(unsigned char type, struct printk_buffer *buf) { static const char types[MIGRATE_TYPES] = { [MIGRATE_UNMOVABLE] = 'U', @@ -4838,7 +4838,7 @@ static void show_migration_types(unsigned char type) } *p = '\0'; - printk(KERN_CONT "(%s) ", tmp); + printk_buffered(buf, "(%s) ", tmp); } /* @@ -4852,6 +4852,7 @@ static void show_migration_types(unsigned char type) */ void show_free_areas(unsigned int filter, nodemask_t *nodemask) { + struct printk_buffer *buf = get_printk_buffer(); unsigned long free_pcp = 0; int cpu; struct zone *zone; @@ -4950,8 +4951,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) for_each_online_cpu(cpu) free_pcp += per_cpu_ptr(zone->pageset, cpu)->pcp.count; - show_node(zone); - printk(KERN_CONT + show_node(zone, buf); + printk_buffered(buf, "%s" " free:%lukB" " min:%lukB" @@ -4993,10 +4994,10 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) K(free_pcp), K(this_cpu_read(zone->pageset->pcp.count)), K(zone_page_state(zone, NR_FREE_CMA_PAGES))); - printk("lowmem_reserve[]:"); + printk_buffered(buf, "lowmem_reserve[]:"); for (i = 0; i < MAX_NR_ZONES; i++) - printk(KERN_CONT " %ld", zone->lowmem_reserve[i]); - printk(KERN_CONT "\n"); + printk_buffered(buf, " %ld", zone->lowmem_reserve[i]); + printk_buffered(buf, "\n"); } for_each_populated_zone(zone) { @@ -5006,8 +5007,8 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) if (show_mem_node_skip(filter, zone_to_nid(zone), nodemask)) continue; - show_node(zone); - printk(KERN_CONT "%s: ", zone->name); + show_node(zone, buf); + printk_buffered(buf, "%s: ", zone->name); spin_lock_irqsave(&zone->lock, flags); for (order = 0; order < MAX_ORDER; order++) { @@ -5025,12 +5026,12 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) } spin_unlock_irqrestore(&zone->lock, flags); for (order = 0; order < MAX_ORDER; order++) { - printk(KERN_CONT "%lu*%lukB ", - nr[order], K(1UL) << order); + printk_buffered(buf, "%lu*%lukB ", + nr[order], K(1UL) << order); if (nr[order]) - show_migration_types(types[order]); + show_migration_types(types[order], buf); } - printk(KERN_CONT "= %lukB\n", K(total)); + printk_buffered(buf, "= %lukB\n", K(total)); } hugetlb_show_meminfo(); @@ -5038,6 +5039,7 @@ void show_free_areas(unsigned int filter, nodemask_t *nodemask) printk("%ld total pagecache pages\n", global_node_page_state(NR_FILE_PAGES)); show_swap_cache_info(); + put_printk_buffer(buf); } static void zoneref_set_zone(struct zone *zone, struct zoneref *zoneref)