Received: by 2002:a05:7412:e79e:b0:f3:1519:9f41 with SMTP id o30csp259132rdd; Wed, 22 Nov 2023 15:25:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IHodMqSOEl/6rOJ/c9bdloRiNI3fxNCGgD8/DBNM84rR4eBLteZDwyualqu5oMzb/6KCLP7 X-Received: by 2002:a05:6808:abb:b0:3a7:330d:93da with SMTP id r27-20020a0568080abb00b003a7330d93damr4065955oij.19.1700695535504; Wed, 22 Nov 2023 15:25:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700695535; cv=none; d=google.com; s=arc-20160816; b=Ms/t++UOGOXPIgDpI2WQpDdGH4jhwr7bx1WzvZHD2KljmkSpldz361mMJuOFqP1zJW kHfC9E7/cI+YxO20nO9sdFNKDPUFAFW9mLdAmGf1PD7qOExLNyehRstPJFyUvXDgpMqd rF5uDErtyP9c2moQJ5/3k96PQE4Hl03jIKczhfwLcIwRE0F5+MbeM2WSnIwBfutE2dbz Bw2pHiCNW+pVq+hQVtw7i49sxRALte0ipHsWlz3EISmckr1uWEFPn1fMxrTG2nVqgVYU 1J1Bdefbjw0/N2qU0GJ1RB2WoW/rALJW2+spIrgEdQbq/tjgXOdbT/p6yJoAiWSD5ivo e5XQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=YRuFFmQdC+GEPgfI4SIAkxSEqgU4CuzXncjpbXVOgmA=; fh=E4i1WlDjTcv4PaggG9LiH5M0StK1kb2o4G2+VCXOoG0=; b=WcCWlT6wSvkWkv/MLAX76kMISVeUz1dgh7Ht9Kk+Hx0pwHMoJ2xtsiMRl8+NP0TZGv cHw1dtHNAe+CdqHipzXdhRzahtKgF5sFAiVrHZLW5mw5lffgcAAkUJ8CgbRq0p7DuohH WZ/Jnrpr6e5NryChpnnzqFeKuzBY9VS1z6BTnKP5vuiC7Kehgx6xBhjojUpVFZ3BICK6 ilWkNxan6YceJN1blTyPc1XlnMnmEClHY2U0yOcJg3RItBWEJWsk3khi4S7AKnAk1Suc iR04SW8GjrCEECfUlL6QO7tU1t4UcFxLfPwGhhBDJqu7kaErF0tRCbNAp9CsmLS7cBYF cFYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OYAGGmY3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id l27-20020a63ba5b000000b00578d460cd7esi101484pgu.431.2023.11.22.15.25.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 Nov 2023 15:25:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=OYAGGmY3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 61198827FF8E; Wed, 22 Nov 2023 15:25:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344350AbjKVXZd (ORCPT + 99 others); Wed, 22 Nov 2023 18:25:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37806 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232389AbjKVXZb (ORCPT ); Wed, 22 Nov 2023 18:25:31 -0500 Received: from out-186.mta0.migadu.com (out-186.mta0.migadu.com [91.218.175.186]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F06A11F for ; Wed, 22 Nov 2023 15:25:28 -0800 (PST) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Wed, 22 Nov 2023 15:25:34 -0800 (PST) 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); -- 2.42.0