Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp1951517ybg; Thu, 30 Jul 2020 06:59:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzARncDrVOWC7SLx52DoTSy55KI13p+E9JEuviJud+mTnwowT9G1C/5ULZ/Puca0OHGUQwk X-Received: by 2002:a05:6402:7d5:: with SMTP id u21mr2728119edy.235.1596117554993; Thu, 30 Jul 2020 06:59:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596117554; cv=none; d=google.com; s=arc-20160816; b=VHnkSSBS6+tTaIMmflOgMIgoLskp6ED8SbOHbjTBb8zl1skZ7pQYfZ3Ci95qyhMdmj bCAf4HSWM6vZH/6HQBjRzYDLEA/s52RbT5aax6olojCsTYsgaFH6+LRqtdSjKBAB0QES j9mOzlOJJqYbOg1AFShGJSz/Vbi2xEhxW/pQAVheBhZTHHL1k0tllZS8KDhL3cRqXyV1 dwChn8N7bBBgIkBZpI+HeFAgRf54vfjZ0PQTaZMBSHvnTmYiy1guoiIGHdJEWQq0RRc5 SSwQhQtqAjmGwpbiQdJAYYJjcSJXJw3olkQ7+IpPtBukDCfiJtVG2GmGp050o4xqSYOc t8Eg== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=oodRMFJVqQ8MmMJSYhhmFTFgO1C8CAbmBJGhHd1vnnI=; b=1AH40qS7RpQhSZd4aI+zHOLYsJRUaa4tU2HFlrONHK+h6nEjLrELTfFmg4y6oR7vyi OGNI1f6XnoZx7x4Sp35gQbkiP2GtzvIgXk9PoX56o1aA2wLR32/3fqRY3nG3kiR534NB 26LPLn4j4xN1VsjWcbkMJnirLXxKa6Pyx3kLgQ+77S93TIwFfXx3Gaoq7jXzK5KcE/Dn 4wXNoAPLUdZUN2sdqoKKUIDjK+d2t0gDuhUnVqsrswJdtyZoMf5CYyv6Jx1LJHrtXmlx 9chF/Vo1WnGudQk7HXLxWgp37hFxhaiCiVyfZw5erd2IG465DfsiNatb16cvKhQ4o2Fi E4Gg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q10si3234564edj.156.2020.07.30.06.58.53; Thu, 30 Jul 2020 06:59:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729341AbgG3N6o convert rfc822-to-8bit (ORCPT + 99 others); Thu, 30 Jul 2020 09:58:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:36836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgG3N6o (ORCPT ); Thu, 30 Jul 2020 09:58:44 -0400 Received: from oasis.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 90C062074B; Thu, 30 Jul 2020 13:58:43 +0000 (UTC) Date: Thu, 30 Jul 2020 09:58:42 -0400 From: Steven Rostedt To: Zhaoyang Huang Cc: Ingo Molnar , chunyan.zhang@unisoc.com, Zhaoyang Huang , linux-kernel@vger.kernel.org Subject: Re: [PATCH] trace : use kvmalloc instead of kmalloc Message-ID: <20200730095842.3e438960@oasis.local.home> In-Reply-To: <1596107052-25682-1-git-send-email-zhaoyang.huang@unisoc.com> References: <1596107052-25682-1-git-send-email-zhaoyang.huang@unisoc.com> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Jul 2020 19:04:12 +0800 Zhaoyang Huang wrote: > High order memory stuff within trace could introduce OOM, use kvmalloc instead. > > Please find the bellowing for the call stack we run across in an android system. The scenario happens when traced_probes is woken up to get a large quantity of trace even if free memory is even higher than watermark_low.  Please limit your column width in the description of patches to 76 characters. > > traced_probes invoked oom-killer: gfp_mask=0x140c0c0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=(null), order=2, oom_score_adj=-1 > What does this traced_probes thing do? > traced_probes cpuset=system-background mems_allowed=0 > CPU: 3 PID: 588 Comm: traced_probes Tainted: G W O 4.14.181 #1 > Hardware name: Generic DT based system > (unwind_backtrace) from [] (show_stack+0x20/0x24) > (show_stack) from [] (dump_stack+0xa8/0xec) > (dump_stack) from [] (dump_header+0x9c/0x220) > (dump_header) from [] (oom_kill_process+0xc0/0x5c4) > (oom_kill_process) from [] (out_of_memory+0x220/0x310) > (out_of_memory) from [] (__alloc_pages_nodemask+0xff8/0x13a4) > (__alloc_pages_nodemask) from [] (kmalloc_order+0x30/0x48) > (kmalloc_order) from [] (kmalloc_order_trace+0x30/0x118) > (kmalloc_order_trace) from [] (tracing_buffers_open+0x50/0xfc) > (tracing_buffers_open) from [] (do_dentry_open+0x278/0x34c) > (do_dentry_open) from [] (vfs_open+0x50/0x70) > (vfs_open) from [] (path_openat+0x5fc/0x169c) > (path_openat) from [] (do_filp_open+0x94/0xf8) > (do_filp_open) from [] (do_sys_open+0x168/0x26c) > (do_sys_open) from [] (SyS_openat+0x34/0x38) > (SyS_openat) from [] (ret_fast_syscall+0x0/0x28) > > Signed-off-by: Zhaoyang Huang > --- > changes since v1: change kfree to kvfree > --- > kernel/trace/trace.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c > index ca1ee65..8d70c79 100644 > --- a/kernel/trace/trace.c > +++ b/kernel/trace/trace.c > @@ -6891,7 +6891,7 @@ static int tracing_buffers_open(struct inode *inode, struct file *filp) > if (trace_array_get(tr) < 0) > return -ENODEV; > > - info = kzalloc(sizeof(*info), GFP_KERNEL); > + info = kvmalloc(sizeof(*info), GFP_KERNEL); The above is a bug. It converts kzalloc() to kvmalloc() instead of kvzalloc(). -- Steve > if (!info) { > trace_array_put(tr); > return -ENOMEM; > @@ -7017,7 +7017,7 @@ static int tracing_buffers_release(struct inode *inode, struct file *file) > if (info->spare) > ring_buffer_free_read_page(iter->trace_buffer->buffer, > info->spare_cpu, info->spare); > - kfree(info); > + kvfree(info); > > mutex_unlock(&trace_types_lock); >