From patchwork Wed Nov 22 23:25:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kent Overstreet X-Patchwork-Id: 13465558 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 90BDBC61D97 for ; Wed, 22 Nov 2023 23:25:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 134716B05EB; Wed, 22 Nov 2023 18:25:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06E136B05EC; Wed, 22 Nov 2023 18:25:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DB3FD6B05ED; Wed, 22 Nov 2023 18:25:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C16676B05EB for ; Wed, 22 Nov 2023 18:25:29 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8956AC16DA for ; Wed, 22 Nov 2023 23:25:29 +0000 (UTC) X-FDA: 81487173978.22.7556182 Received: from out-178.mta0.migadu.com (out-178.mta0.migadu.com [91.218.175.178]) by imf06.hostedemail.com (Postfix) with ESMTP id C39D7180020 for ; Wed, 22 Nov 2023 23:25:27 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=OYAGGmY3; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1700695527; a=rsa-sha256; cv=none; b=L114y/x7JttG0qT1tEkDCHoLibKmiw9rQTjbIjf8hdCOg7x9c//gFTUNmfUtnUvsuQekb/ wLxllQqLdvBTv4jD6HtF1CxM5Zi0n95SgaB1HEoPO0/bOt5FSSuFz9qoqBpmsgVN6vidBv K9EEW2wgGdOLJxEuoH3rV85q4snvbz8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=OYAGGmY3; dmarc=pass (policy=none) header.from=linux.dev; spf=pass (imf06.hostedemail.com: domain of kent.overstreet@linux.dev designates 91.218.175.178 as permitted sender) smtp.mailfrom=kent.overstreet@linux.dev ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1700695527; 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=YRuFFmQdC+GEPgfI4SIAkxSEqgU4CuzXncjpbXVOgmA=; b=aGasRzfOtr2qEwdpKdOvaZl8TfZV0mD0W0SP4jXu0255f+SNNZkNtuoxrzS6kKYlU+iW+7 Sx0lO1N64SwxrmVvUawbIlUk0TqTAuiOHQpjWCYUR+cwCdQ7J8xXpTer3hTMwKFrbq2nvH O2PvYD67fHl5HGzp6KjN2dwwiqzvxmk= 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=1700695526; 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=YRuFFmQdC+GEPgfI4SIAkxSEqgU4CuzXncjpbXVOgmA=; b=OYAGGmY34QArkmiHjXDebJ27PVWXyHMvnQZdKucHfTgjB1wcWYWZBFp8TmHRA8jCBIi8v4 yvW1Y2FRd872H0c4q3qoiHR5jVSk8jX1HncoAHfmzh1blP3uywzK+6Ze2zyzcQKJnohAOI ZqfJdF5DZ+e1jm6U7nga+mewJb4vhXs= From: Kent Overstreet To: linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Kent Overstreet Subject: [PATCH 1/7] seq_buf: seq_buf_human_readable_u64() Date: Wed, 22 Nov 2023 18:25:06 -0500 Message-ID: <20231122232515.177833-2-kent.overstreet@linux.dev> In-Reply-To: <20231122232515.177833-1-kent.overstreet@linux.dev> References: <20231122232515.177833-1-kent.overstreet@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: C39D7180020 X-Stat-Signature: xobje7m9afx4xxwprdjgiedezk8ugonz X-HE-Tag: 1700695527-637798 X-HE-Meta: U2FsdGVkX19hBZfDoBn6FYstbfnEreZhwO//8TC2kJ9A/aql6hBAIceY9yC1BOkim2idwtppmbDLRUkPLr2xaKDuKae5bB+YC5Q3xxERktLq6B8ha4MFb8z6xJLkvFdBz/eEacrk7fs2abI1WNfSM1Em+N9n/wDRRswcyC1KrYDOLRrpVNPcXkQ1s5ji5TkQTkoQ7YI+F9jC1kPObPd7JQZnjucNJRcwT8SWwv6tD9BSUrHQlok2LVZ0fm34X8AU0Tn9gU83ijmUYT3AA5RbHF8HGP0TsqCsyQ1UgwVeuxgRumJzVMovEwTACIoNkWVcYmhBVwzZtW+G/N+pi1qOvdf33r1l+PP/EHp9cTsqVJn8EUuqRuSNjhTLjxL0ruWjh0qxDBA5CkoqcNcbLtlxY5kbTlGin8MZLtuWiPMH9Sb4AVhJ+1xEr2S5NQj98+3MIfE3rUeVQ/RdtDNN/zIV5SL2LBFn34y1NztUAnLYEvItZ3lEEQIiYXrUC7FM4IWH8Yz0JRvYWl9rE/ktsD09dVOJndVVU7G8BfFpdreoq5VtRFJd7c0m7e6eTes9D8MINj6OT8x1pO9ouXKtSjsmsO5mG/By6uglWawKEXYgObaR4CmhtoSC1sJs0cdKJiHIvGB1vhDRbAw2FydaCpfFrldyqpMBiCuctUibyX+ZpjGC2o1WD0XUp4EWp7Pnrae1JNz7SPIJ+ZP9dCztpORvujtKn0mzmSI7Ri98nuFxeEtDLQsARTV01kAScOtT2fl6BKoRgft1iwm88vJjtioQ8P1dZXuqL2uQ+vmno0zLSiXLi4KJ9Gr0q1iVzv/7LgyRn6gJanv0L8Qsx2sI/k/OcUBE3ER+BVpFF3y7L8GZ9WB5lojT1PQw0zFxFyegot5ECxgspzg0eRwdLLdICPUO3JzBEtcTobENXV9JeuPooYMm/6hNbxgqh9WTMw/h0gyyd9Uc2GrE/3kIxRCIDnN hYLHBTnd od+AtlUirc48mgowxWjckI3ZFFFT664syB4V2Wzc9oKoZF6w0nSxBSAA6vfs2zVSgEEhHBalP1aY7KnxsmRdNNtADuVMyjOvz4UEz88y5JSzY1kW4rIbi04yfNGCvuPxnwEVa 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 5fb1f12c33f9..dfcd0f367d6a 100644 --- a/include/linux/seq_buf.h +++ b/include/linux/seq_buf.h @@ -171,4 +171,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 010c730ca7fc..9d4e4d5f43b4 100644 --- a/lib/seq_buf.c +++ b/lib/seq_buf.c @@ -425,3 +425,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);