From patchwork Sat Aug 24 19:10:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13776492 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C656C5472E for ; Sat, 24 Aug 2024 19:10:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2DCA6800ED; Sat, 24 Aug 2024 15:10:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 264E8800E9; Sat, 24 Aug 2024 15:10:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 001386B0487; Sat, 24 Aug 2024 15:10:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id CE3906B0487 for ; Sat, 24 Aug 2024 15:10:32 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 6AE5280894 for ; Sat, 24 Aug 2024 19:10:32 +0000 (UTC) X-FDA: 82488080304.26.A9BBAB3 Received: from out-175.mta1.migadu.com (out-175.mta1.migadu.com [95.215.58.175]) by imf11.hostedemail.com (Postfix) with ESMTP id A1A4940009 for ; Sat, 24 Aug 2024 19:10:29 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=xZ4wABTa; spf=pass (imf11.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.175 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724526546; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=z4DTT9AInmX29fCUItJ/fQQQ+2P1VUsJ4Sn1mHHvlmQ=; b=yw2OeVZlONagBTvWbi6rnTr2mQOxUzgOy4scEKwtrMiLQNyFBnFYjchooC5UqbX7pzNe9z FwJTzqF9Vs8kKMxia0OjIe1PGJbW9m/jWzwgagGLMizwrPva6OmczViQiM2i/So+kF4zed OFAiSr3TytRO4WB8MNWPN1mFvzafGuI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724526546; a=rsa-sha256; cv=none; b=jPn68jbW0ir5gXkA1+2nHfXOC3tDYhqEgT0dZyexxbRHsTgiGvXwYifPG3rG3PLVI2eEri kd8WTXRdsLt6aYWHOBLSTa1Qp/bWmGp2IRDOmZz5Y43oANNkI+0djO+5/8LtEtcKOz6DKh i/yREObM84/XjyI1Mtd3AI7ilTX7s9s= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=xZ4wABTa; spf=pass (imf11.hostedemail.com: domain of kent.overstreet@linux.dev designates 95.215.58.175 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1724526628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z4DTT9AInmX29fCUItJ/fQQQ+2P1VUsJ4Sn1mHHvlmQ=; b=xZ4wABTa6vq9Jts/HvTDzs72F9781v3Yg3ujOS8GOgj0WFCPwq6S9/orkPTgPVCY4WSYa5 gDzPJ5Ixpp0Fqgwr1wM1P5LQvy6SVpl8XcxOR7KKH0UOUDyANYepoPgZYCcda1oZaaNMGu k2LZBiYiqsm6IX5U40ahz8xqUJE54r4= From: Kent Overstreet To: david@fromorbit.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: Kent Overstreet Subject: [PATCH 01/10] seq_buf: seq_buf_human_readable_u64() Date: Sat, 24 Aug 2024 15:10:08 -0400 Message-ID: <20240824191020.3170516-2-kent.overstreet@linux.dev> In-Reply-To: <20240824191020.3170516-1-kent.overstreet@linux.dev> References: <20240824191020.3170516-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A1A4940009 X-Stat-Signature: wkiy5ej8y8hgkrizseezu6tr3wnwoz3r X-HE-Tag: 1724526629-946327 X-HE-Meta: U2FsdGVkX18qEwsrPkzF4ZF+z5zgzwKCtI8WgMEUZ1uh+ZsPbG/7rkolPXxi7K9xDJHZepQILGLxZlXkr3gfXHn8wRJBwjYqWNJq07KkL5N7uvKO+gqimpY/oEINl5BCbcNHbkDdIAtJ2GNXw3o5WjUoYlRFpRz2h5dx53uwkQG0nYQ4chsm+b0kyyWQC+N9sHKvx2C4F9n6iOsNEHJunxB5myudVqwsN+PYj9cqHMtE1ua1hC1WxbAVfdY+Hvrtl4ucsI5OnK0WezgWh2fnZKXhZEPUCI+5R2eh6r/MOPqdGTNQQxi06xWRXlG0q63r5H+ekaFdRYxDiFUXzW272Px/lK87X/IGdU0GcVqHWqf3uuGkPawjyxNLGxCg3vvXcAXLnn11zEaH9c9p01j1qwsWDXYoaY5xxtsZ/dH4LCWoJZaVogMeV7sEk2ovNOSehJu+Lbdj86RrcPojbiXuh4yQllgNxbiXHDR4jx7cSUSKet/VLSAG0gJ3/ga5uNAwDxJQGETczCzN9GO/83E/7abE41mg8p5mi21PReDVEkv60zYgA/uVe4GWap7On3QCi9b3Z4z5i3vlJVce4vB4vPYOlGS+9G0D4B+Sme+vOfX84Jv/eTiPqa4SG4ZBLMAvnwnpPR6Y4PhoFg4jtm8OjkV+IC5EjVOHJUx/Kmgu7Cb6An4pjLMm5Kl/wImwghkZB7MKVJnN0pp36UHtPc+d5CicO3HcZ3XHbJ2FQTnEikSi8ll14oEu1yvqZh6k2dez7URdMOEBEYBW8mGV34fhgZr5uaneYl4Jpi08NjYM+deftlwlJrVv10IDElu6zX5tcovi2FfHWn6hiN7+thn6WgwtnHYRKReZCGeD4pPzOy8JxplQst9X3G/w14rXIyslXAqF1eJrMUlqQGzB71L1LHXAjYZca+S24jWXCR3B2vM8z/t3TwWG4qp8vtnSriAFbDac5AtZtkDBDkLb754 grG3qxmN XNYmDrgBun118oTaiUNfQ9/i43SSrSoIqIpMjF1ePQtTwQCn2hFQEjlw2+oeSWApJ+0Hvz+jaNDDHcR3ZMk+nSc2/GxGI/7fyWWOxkuz2LzmP9HRU07n+yQ1BOQw6DxSm27rJvbtLNb4+SSLmu4IAD9Vf5g== 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: List-Subscribe: List-Unsubscribe: This adds a seq_buf wrapper for string_get_size(). Signed-off-by: Kent Overstreet --- include/linux/seq_buf.h | 4 ++++ lib/seq_buf.c | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/include/linux/seq_buf.h b/include/linux/seq_buf.h index fe41da005970..1cba369e1821 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -173,4 +173,8 @@ seq_buf_bprintf(struct seq_buf *s, const char *fmt, const u32 *binary); void seq_buf_do_printk(struct seq_buf *s, const char *lvl); +enum string_size_units; +void seq_buf_human_readable_u64(struct seq_buf *s, u64 v, + const enum string_size_units units); + #endif /* _LINUX_SEQ_BUF_H */ diff --git a/lib/seq_buf.c b/lib/seq_buf.c index f3f3436d60a9..3c41ca83a0c3 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -436,3 +436,13 @@ int seq_buf_hex_dump(struct seq_buf *s, const char *prefix_str, int prefix_type, } return 0; } + +void seq_buf_human_readable_u64(struct seq_buf *s, u64 v, const enum string_size_units units) +{ + char *buf; + size_t size = seq_buf_get_buf(s, &buf); + int wrote = string_get_size(v, 1, units, buf, size); + + seq_buf_commit(s, wrote); +} +EXPORT_SYMBOL(seq_buf_human_readable_u64);