Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1632978pxb; Mon, 13 Sep 2021 01:54:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgXoXGQxSf7nC1XI8ouMV0Yk+lmhV3/OnvttmYfskVQHIczFj7Ap9x1PSbGMoLAu/JHWBu X-Received: by 2002:a17:907:7704:: with SMTP id kw4mr11725698ejc.23.1631523261150; Mon, 13 Sep 2021 01:54:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631523261; cv=none; d=google.com; s=arc-20160816; b=i1wnZmEy307kyrgOlVX5/7XfMlaZXXtAeCchUJIQBml75pcpb6HAdMOUZH/f6YbUxD 90eSTw8dCeQT7KxsJkSFt2HK+Ul9wBjocf3u+SVsYzopG+kK1gn4V7oVtC4dfP2Mg2Jv PRZOPev832cm717xoFjBHWMmnGxQUZ36OMUkq12dAzVYw7l4TjMc70J5ZVEheXiYy3xv Go3xypHPW75rigqsHgSBiipHjEw3Xke+F1L7PIs5UK3t0+SVT75sUI9ew+mue2XSnQQ9 1OT+Vp6OCDtpn9TaqWI4XVD+HO8B3X1kZrOMUcroX1lEycOVG3LGiqnd8UszdbuaOVYm RpPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature:dkim-signature; bh=ksFxQBzI29xFmDbHIj8YRmkVKqt6DAsFXs/2K5yf7c4=; b=AMs9YJM1ieh9Uysk5dzDRfTxS4J1e7PIMNTQranyRUNzBUw1o1WOkroUi33irk101I a0hSQHpb+scJBDH5Lv1aJPqPIMp6Vai/UshpG61wfbsy4/FFUvWHk0HQ/UnfJ2vgzNC/ 2QFSXhns8I8OjVPPfB7JANBgsSYTsZLngZ9u0vbqGk8h/N9Bmt0iA0Hz/lk3BKGcGmG0 98Xpqd8DX3Uwuphtjdi0dKRkTcXV+EQUdJR7V5az3uR15f6X2xWMa0+6c0Dx2sw7p2/6 mnAl279TiKS2G5/vlK5ZmM5oNgzaeaPGnCD04aeutilBwq7A/JpIm2pqABucBBezoOhx DwfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mWaZYv8s; dkim=neutral (no key) header.i=@suse.cz; 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 p21si7065526ejn.229.2021.09.13.01.53.57; Mon, 13 Sep 2021 01:54:21 -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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=mWaZYv8s; dkim=neutral (no key) header.i=@suse.cz; 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 S238156AbhIMIw3 (ORCPT + 99 others); Mon, 13 Sep 2021 04:52:29 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:52060 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235987AbhIMIw3 (ORCPT ); Mon, 13 Sep 2021 04:52:29 -0400 Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id EA4DD1FFAB; Mon, 13 Sep 2021 08:51:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1631523072; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ksFxQBzI29xFmDbHIj8YRmkVKqt6DAsFXs/2K5yf7c4=; b=mWaZYv8s0o2ZUZUWpNbCiBgCD+yz9uluFPXIxp0Z2mPZuoJLxcu0peePL09mKaSTi4jk5y U5aV15eaVQYBTzOqItJCLO9hejLns0sWXroVoUvCDsAhWBLgWnf0H0vsCaupQIe928fowv 01gLcdBgKAAgBrpIWpKcWtzU1mOkFpk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1631523072; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ksFxQBzI29xFmDbHIj8YRmkVKqt6DAsFXs/2K5yf7c4=; b=L4mz27K61cl+RnXEHUjQKHIVRNv/c3yKjZWxAJSyhmjAGjDWOGWxecV34k3zLv+xDmkqgK v/cq/hq6XxXwGuCA== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap1.suse-dmz.suse.de (Postfix) with ESMTPS id B07A5132AB; Mon, 13 Sep 2021 08:51:12 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id MMvSKQARP2F+FwAAGKfGzw (envelope-from ); Mon, 13 Sep 2021 08:51:12 +0000 Message-ID: <464d76e2-37f0-87f3-a9d5-2101367a8ca3@suse.cz> Date: Mon, 13 Sep 2021 10:51:12 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH 1/1] lib, stackdepot: Add helper to print stack entries into buffer. Content-Language: en-US To: Imran Khan , geert@linux-m68k.org, akpm@linux-foundation.org, ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, maarten.lankhorst@linux.intel.com, mripard@kernel.org, tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mm@kvack.org References: <20210910141001.1622130-1-imran.f.khan@oracle.com> <20210910141001.1622130-2-imran.f.khan@oracle.com> From: Vlastimil Babka In-Reply-To: <20210910141001.1622130-2-imran.f.khan@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/10/21 16:10, Imran Khan wrote: > To print stack entries into a buffer, users of stackdepot, > first get a list of stack entries using stack_depot_fetch > and then print this list into a buffer using stack_trace_snprint. > Provide a helper in stackdepot for this purpose. > Also change above mentioned users to use this helper. > > Signed-off-by: Imran Khan > Suggested-by: Vlastimil Babka Acked-by: Vlastimil Babka A comment below: > --- a/lib/stackdepot.c > +++ b/lib/stackdepot.c > @@ -214,6 +214,29 @@ static inline struct stack_record *find_stack(struct stack_record *bucket, > return NULL; > } > > +/** > + * stack_depot_snprint - print stack entries from a depot into a buffer > + * > + * @handle: Stack depot handle which was returned from > + * stack_depot_save(). > + * @buf: Pointer to the print buffer > + * > + * @size: Size of the print buffer > + * > + * @spaces: Number of leading spaces to print > + * > + * Return: Number of bytes printed. > + */ > +int stack_depot_snprint(depot_stack_handle_t handle, char *buf, size_t size, > + int spaces) > +{ > + unsigned long *entries; > + unsigned int nr_entries; > + > + nr_entries = stack_depot_fetch(handle, &entries); > + return stack_trace_snprint(buf, size, entries, nr_entries, 0); stack_trace_snprint() has a WARN_ON(!entries). So maybe we should not call it if nr_entries is 0 (because e.g. handle was 0) as the warnings are not useful in that case.