Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp4024143ybz; Mon, 20 Apr 2020 14:05:38 -0700 (PDT) X-Google-Smtp-Source: APiQypJXtgDECAsrpTM/91eSuv2Fn2646hZKZcJ4c6HDbdMhhKAPSB4V9tMQMBOqOeaqQE5fk+av X-Received: by 2002:aa7:d64e:: with SMTP id v14mr16000808edr.19.1587416738492; Mon, 20 Apr 2020 14:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587416738; cv=none; d=google.com; s=arc-20160816; b=uCxC0qdUJ4KJu35GWKEaSaFiQW+pfmST70/Z4gYvsZDgCb/7zyEjof8OpnRCELj3DE PivkCKAMmlSzvKB4Y1Cx5QQQfRyjcXucL+dpdFlpQn5E8nGAVY6b4AaL8sH3fAzZYklB 6VS18dO/RJlxlTkA7SFRxA167TOsRHrnoXnI9EX/ibcRYNi5b+IHcK5JTX1H14dYsHnL s5/Rl/2Xdp/pxEI8KpAuHqPCA/ipOpN4ZMSqQujvxWWabuBMfiLCXZFPEc5/1o8L4DKy M4iU7Wa21HP0mjf9ppcfazg+EOgBnj4AqBGdPIl6Own91HLjFnG/9lO0k0M0MhrzfuAh xkkg== 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:date:subject:cc:to:from :dkim-signature; bh=qUn+GLd9ydpqdPTxEVmckTZm3FvpDIuZEv3pyNzEsmI=; b=BTusCqdJaqMkFMm/Q6dSFFEb0YKHRpkN71IFTXS1pBdzz9+jOnsVTKVtHYpyUxShNh UcxlTCuefzktPvr+S1V8d+szyvorZF4AyosOCHTxnHBQxhwJ2W/NnpPIg/DP+ZHzlpeZ uZ+7FbsRbI/2MnV+xqg0D7goSCmpAbU3M76QfLgjgRa+I/iHgzKdJDTZBViJSe8SpcxU aWzFCN9qOzCvrdh0HnDtcsDaPeJ52Yfw3ng4Ot7kr4yWO8wnVNA6ZGinUxxwewkUpHKA kRTWfk7DXmRDLVyYRZ40u14/IFUNX58Vi53j4JxXJG+3IuvrT/D4GGrBGnyTX2hfYS/d L24A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cVYB1Rus; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dn15si310405edb.555.2020.04.20.14.02.32; Mon, 20 Apr 2020 14:05:38 -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=@gmail.com header.s=20161025 header.b=cVYB1Rus; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728345AbgDTU6y (ORCPT + 99 others); Mon, 20 Apr 2020 16:58:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727768AbgDTU6Q (ORCPT ); Mon, 20 Apr 2020 16:58:16 -0400 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C11DC061A0E; Mon, 20 Apr 2020 13:58:16 -0700 (PDT) Received: by mail-wr1-x443.google.com with SMTP id k1so13962033wrx.4; Mon, 20 Apr 2020 13:58:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qUn+GLd9ydpqdPTxEVmckTZm3FvpDIuZEv3pyNzEsmI=; b=cVYB1Rus+R9pIeYMUG/QWduWz8K0rywd1BdDprPoH5NmUE9TEHIeieWn4I5UtcZXhg AyaID9QQKsSgQ8LrOLZJJ1cMhKQqBCDoG+A5U8UQiPjK1TlqC2VnQ2MMy76+0+PHCo4t 3R2k6HmH/LJgf/BE5Niegz+/axjbBwrLwwBATULZHt64yUlaBLiAVtVavu6wpP+RhUPy 93WlOtfMRW/1OBOTdnrX2t8Ena89qXM8eHVa1YHLCNgu5FIZI2UQcKl+d97yqLXzOdp5 +M4+vHMubQbYmAyA4evnQ+XH36tHh+P3fK6WFdgABqCPMrOIkEYATgXHWkSjobU9o3Hm 8jpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qUn+GLd9ydpqdPTxEVmckTZm3FvpDIuZEv3pyNzEsmI=; b=epLzA4tC37gm2xCxZe9mTRZn+Y8OtONqvZYMUaQvAPp9bTVlak9r47b/VyDH11df2+ IZZO5QqvfYtoPPTwGR4EgVW0wfhVlSfa1OUK49em3XYaGrmnuv/UYPJROEW70SMzLSzH 5Eg8/Pc5Ar+muJeTEvvTLrPqYskhHOrAr4a6XKv53aqBT106Wn+Xi4bsSOeLCRNah1dv eXaX/EB9GPRPUwNcb9lc+oj4Lltzk2iZ5Jfg3Nw4AGTCziljjJu5xxiH7sBbSiagW9W/ ozQ/Q8sDd+cOY7x1phbDFi191wjmJj0xUOZNx1In/I/Be6wscdQ4pF60XL/tLzNAJBbT f3lg== X-Gm-Message-State: AGi0PuYSR2cdArMyqnZ6c6G2WLd+0NDHtOwXOok4ru9+f9fnGxYOgWYa PAFXiDGsLuP8bf5uyrayLw== X-Received: by 2002:adf:fc4f:: with SMTP id e15mr20763529wrs.415.1587416295092; Mon, 20 Apr 2020 13:58:15 -0700 (PDT) Received: from avx2.telecom.by ([46.53.249.74]) by smtp.gmail.com with ESMTPSA id m8sm863069wrx.54.2020.04.20.13.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Apr 2020 13:58:14 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: adobriyan@gmail.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, pmladek@suse.com, rostedt@goodmis.org, sergey.senozhatsky@gmail.com, andriy.shevchenko@linux.intel.com, linux@rasmusvillemoes.dk Subject: [PATCH 08/15] print_integer, proc: rewrite /proc/uptime via print_integer() Date: Mon, 20 Apr 2020 23:57:36 +0300 Message-Id: <20200420205743.19964-8-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200420205743.19964-1-adobriyan@gmail.com> References: <20200420205743.19964-1-adobriyan@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Alexey Dobriyan --- fs/proc/uptime.c | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/fs/proc/uptime.c b/fs/proc/uptime.c index 5a1b228964fb..a8190078d595 100644 --- a/fs/proc/uptime.c +++ b/fs/proc/uptime.c @@ -8,10 +8,14 @@ #include #include +#include "../../lib/print-integer.h" + static int uptime_proc_show(struct seq_file *m, void *v) { struct timespec64 uptime; struct timespec64 idle; + char buf[(LEN_UL + 1 + 2 + 1) * 2]; + char *p = buf + sizeof(buf); u64 nsec; u32 rem; int i; @@ -25,11 +29,21 @@ static int uptime_proc_show(struct seq_file *m, void *v) idle.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem); idle.tv_nsec = rem; - seq_printf(m, "%lu.%02lu %lu.%02lu\n", - (unsigned long) uptime.tv_sec, - (uptime.tv_nsec / (NSEC_PER_SEC / 100)), - (unsigned long) idle.tv_sec, - (idle.tv_nsec / (NSEC_PER_SEC / 100))); + + *--p = '\n'; + --p; /* overwritten */ + *--p = '0'; + (void)_print_integer_u32(p + 2, idle.tv_nsec / (NSEC_PER_SEC / 100)); + *--p = '.'; + p = _print_integer_ul(p, (unsigned long)idle.tv_sec); + *--p = ' '; + --p; /* overwritten */ + *--p = '0'; + (void)_print_integer_u32(p + 2, uptime.tv_nsec / (NSEC_PER_SEC / 100)); + *--p = '.'; + p = _print_integer_ul(p, (unsigned long)uptime.tv_sec); + + seq_write(m, p, buf + sizeof(buf) - p); return 0; } -- 2.24.1