From patchwork Fri Nov 8 20:34:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178954 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3244658ilf; Fri, 8 Nov 2019 12:35:39 -0800 (PST) X-Google-Smtp-Source: APXvYqxtjDVZillqp9gLli+EIWzfk6flsokMckeOO0oVzg9uB76J6vvjBfcZIUzEzHZdx7AwiNwm X-Received: by 2002:a50:becf:: with SMTP id e15mr12480545edk.135.1573245339036; Fri, 08 Nov 2019 12:35:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573245339; cv=none; d=google.com; s=arc-20160816; b=KNTHVDNlaIpgtg/QTkgzHcm3LM6Fe6T9zW7GbVqQUSrLWJ5m0j5lbmZ0eHidOHi+xV dfUUuOm6BgjHSZCLJjEL5Xqw+1JKsxAn3p70kLJlAzLUhovpUBDwJYbS6YfgUbU9eoCR OsOwsOdHWdSxYSDJyJzb0eaM7y1c3JcofKX2whq95Z/bELBkoPUgNHL73lbJ/xHVSVGc UbOQpq7fpMezaphdbyMwf9th6fuxONnqG07ZUC1xVgTqnpfXL6bq+tcC5+XTlB/aeKiz QcRELN4sKkAGZpSKT0JA36RfzLKm8DeApobYkHgdisAghz4ORqXeUHTtY/373mkXM0Nm zLnQ== 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; bh=W/JAYdQF+yFy9f4qMJgIWaVvSdSTnUwtq5XO0LrUIng=; b=FuhqaFLYRmDEpcw/idjDSGZb2XtYBU68kqmLQdVI26gw3bZPO12vd2hhqOaQgBqaoK ZO6+YqpeEHvqVQBUAO+ao8kE1LFkDdhoXywanREFHoeVo9OTwX80BilY1lhOouPvpenn cqEI50S49lIZ+uJjv1W/S0iT7SieoxcQ+99ba7ziO+i/xFUoGHQxdQOTlEyb7AVNXVYs R7Zz/Px4UXiNxrcckl6WNsJm40Ujd/IMVBE0DRf/8zoVl7g1BpfrYHZLehG+88ybvyVR 5sYQ+gDJavV/jYX8GBvl5j5WcrfOCvDIif3gG+LkauRgIGdSPNBkOQdWMbDY9/KWOQFN pkWg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g6si5946744edk.210.2019.11.08.12.35.38; Fri, 08 Nov 2019 12:35:39 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731911AbfKHUfe (ORCPT + 26 others); Fri, 8 Nov 2019 15:35:34 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:46863 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726843AbfKHUfe (ORCPT ); Fri, 8 Nov 2019 15:35:34 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1M890H-1iXpoO1zD1-005LFy; Fri, 08 Nov 2019 21:35:23 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, John Stultz , Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Stephen Boyd , Deepa Dinamani Subject: [PATCH 2/8] timekeeping: optimize ns_to_timespec64 Date: Fri, 8 Nov 2019 21:34:25 +0100 Message-Id: <20191108203435.112759-3-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108203435.112759-1-arnd@arndb.de> References: <20191108203435.112759-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:p1S8Vm5S9mOTgTtbXxcpOxF1EXzFZzdK9j2/O1Ee3fyzg6An3tR lBZ66pgI6iZBdXJ54mOxMj2nung87BghhEiWfxdG2ow0YQZe3LBxlQHQnjDZSxBjyPP6tsx bfA1fPNf8Y/POpr6MTYVPhxSUZOUYGbIQoes/LWQ9akDbcZ0iPTgN3lULhrc1E8aUwlXJcD AIBfjtmvDO9y5gP5/i1Cw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:JDO+ITcPMoo=:KOb3c4dgHZm81zl2vb18eF pWebkyKHxGEifiJWZ54rdWO4EDw6xCHtWkieKB+x9+7D8OmHsVfjvpETrYQo2wUdAaE0h1h4+ T3+uLnkIkn8wzgp1MBhgy3BtZeAZevrpFrOLa9ymq7Z3Y99Lw1q5dW0OHip+eQCXlsnsBeFlH yTyW9a1FcIopKY5/zJ7SLS6l1CGA/1Y998Zt8dwvZcZYml2lX4lbi5dxrUiAOo6u2u9e82MEg tjY2bZRJuW5F1nGc4q42bxLjo8cJvir56AzHSTuHq1XlPERNu7iaQ4tdBSNx4J4SIkwryAgpU 2cwHhCGxgVwwUfFRwi3XnVA9PSaz8xSEGT7NV6rdZF8+ljVrwb6zwis5Q74WN3EcPbqpyFfH5 QafBvgDWytSz/Yz0kNvhi2zOb32YQul2P4/tvNRxuWvYPwHg0QFaxPjmCVV66ZEJQPjlFN3w7 9TjH0JFkW1xK6IJ3jo9ceK5oPk30o8Rlww+3GNPmAVWKrnsJmGOcwbquhV4hsl8PSG75KwGL2 cZ9sAynyBuBuxxylD0UoPCZYtwDPWgpvNT0xyh2SSWYimErGmmou0gB405flo+sxy3r8b0F+C 3ebXI8xwQRI85xU7NzPN0kVqiKIoYJG5HG7AD3lsRJ5LFRLJ3lScJZlQee69Fd40hBZYariIS ufxBamy4nk5xIjnf3Xx4iuHQDoTcYpcFM5LYYRmgk9Cc3F9T+FMfetnIf5EBA/llIjoJSx2mn wKx4qlGfFdKr7qy/zBQ+x/mLHhPmupOBOEcaZqCiaq0SBvr8YVTjaBYpjxAFQARuNRyGF4DRk NkKFlRRjatiBtoBOQsS1ta16lpSGOxoTm+AFIERp8O+8nHI6DSSACAYjUWZzy3lhltKMIVVWv +Ff45mQWVHAVLgeUCWOQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I noticed that ns_to_timespec64() calls div_s64_rem(), which is a rather slow function on 32-bit architectures, as it cannot take advantage of the do_div() optimizations for constant arguments. This open-codes the div_s64_rem() function here, so we can pass a constant divider into the optimized div_u64_rem() function. Signed-off-by: Arnd Bergmann --- kernel/time/time.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) -- 2.20.0 Acked-by: Deepa Dinamani diff --git a/kernel/time/time.c b/kernel/time/time.c index 5c54ca632d08..45a358953f09 100644 --- a/kernel/time/time.c +++ b/kernel/time/time.c @@ -550,18 +550,21 @@ EXPORT_SYMBOL(set_normalized_timespec64); */ struct timespec64 ns_to_timespec64(const s64 nsec) { - struct timespec64 ts; + struct timespec64 ts = { 0, 0 }; s32 rem; - if (!nsec) - return (struct timespec64) {0, 0}; - - ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem); - if (unlikely(rem < 0)) { - ts.tv_sec--; - rem += NSEC_PER_SEC; + if (likely(nsec > 0)) { + ts.tv_sec = div_u64_rem(nsec, NSEC_PER_SEC, &rem); + ts.tv_nsec = rem; + } else if (nsec < 0) { + /* + * With negative times, tv_sec points to the earlier + * second, and tv_nsec counts the nanoseconds since + * then, so tv_nsec is always a positive number. + */ + ts.tv_sec = -div_u64_rem(-nsec - 1, NSEC_PER_SEC, &rem) - 1; + ts.tv_nsec = NSEC_PER_SEC - rem - 1; } - ts.tv_nsec = rem; return ts; } From patchwork Fri Nov 8 20:34:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178955 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3244781ilf; Fri, 8 Nov 2019 12:35:46 -0800 (PST) X-Google-Smtp-Source: APXvYqyUybODrNQ3zCHbss6Xz93D9bvanN1WBxJ3twYy4xIsV56/SOMH57daR3R4d6bFIAAzlLt9 X-Received: by 2002:a50:b6cb:: with SMTP id f11mr12466856ede.299.1573245346477; Fri, 08 Nov 2019 12:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573245346; cv=none; d=google.com; s=arc-20160816; b=OCwjjdK98IfRi7HAwtvAC+KHSx4E2PE3KNQuQfSzry45X1UdcZ5iLeGiUXU7Ex2XE7 zaZMogDcQED2XydbHUI7aadDzi2H/SAjzcWdVtBUljXB/srGArUsKY4uGza4+t2857np Ch/fQoa5t3qKJT0VQFg7qagYBnTi13tz4327ok5C/sAzeFFOBzYGyYdteu5f6liBKwzq N+MDsNb5rvUVxLl6tHmoJ9P9Lv/bixkXRjTR26cEiQ70+dtcOQL1c+EolOwUbVbWRE2J erQkoztTF8zBfOT2DgaQoqcKpYzlMPoC/t2AYKjyEm43jjbZ8mszm/yfcLThZgVtjSyh DlwA== 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; bh=smx/IkQBHQp7WTqX8wEuunjBeJVo82++Y6rf+4uYjKM=; b=Il9lVQnFbGOjO0WxRJ9RTJi9Z+IJnuSo+LYccLNJAPHXQtJccso1aHOmzXfx6DnoQ1 QQcstyZbyB44ZdIZdpeHMnRKzIKuT0DQ8LCR6kw6mFm/9NCCLDoM9WiIUFYX4+x5SyBP l5r/pk+XoS+8GPOEpPFdyrgeNlcv8s60TmAB8AOfn6B/QueSjZlKVjmucEbMcHBpKpUR x1zqBp/MO+ks1r2NcLxlCVyqzzQDwY2ISX7zhcJYhKLUXp0+xlQBTXgwQTe1KXsNOtZQ qvn6oAaQZWz6ZpK5f0mzRk235R5hPjtTIcDbK7BdP/O1Sm7W3AUrq0fs6yLD7HJEihd3 onwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id oj22si4669364ejb.230.2019.11.08.12.35.46; Fri, 08 Nov 2019 12:35:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732045AbfKHUfm (ORCPT + 26 others); Fri, 8 Nov 2019 15:35:42 -0500 Received: from mout.kundenserver.de ([217.72.192.75]:37893 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbfKHUfl (ORCPT ); Fri, 8 Nov 2019 15:35:41 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MK3mS-1iDApS0zHy-00LVEV; Fri, 08 Nov 2019 21:35:36 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , linuxppc-dev@lists.ozlabs.org Subject: [PATCH 3/8] powerpc: fix vdso32 for ppc64le Date: Fri, 8 Nov 2019 21:34:26 +0100 Message-Id: <20191108203435.112759-4-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108203435.112759-1-arnd@arndb.de> References: <20191108203435.112759-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Dqnz/eT1SOuWZ6Nsk7jZrA5JIgvW92857XvPyhhu/MApAgKJOA1 BSqzR9cR49iuc78Q1Wuwf0uc2LqdFCeF+GpSJDDSjMlUcug174u1+56gDh9aoAZMx1YjAwO T8m537fFb4GJkW3yVU2NiAIGc/zHBxrA4aQsCblV6As0b/E7RzWZwmp+Wb67zGD7CJn4a29 jQARD8KRNeNNsdWXsPuDw== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:z9DAEWseD6Q=:XDnU256Cf828kWUYInolSf bjsDcH8IUWm6SRtKEzuDz1LNDsxNapd9Js8NqFeXQKodJibBTVt1CWq3I+eWNf5bEWjqg6Bmo GMRgQQ5xAisfdxwtgul9EA23xU+fhq5Xi5w9dj+iS1+k8UVSpB3aGo7foX+IPnXesLPuIsaVS Tbkhx7lFVDphXU3OjDCsgfpLKWJ3FZejSwj0JU02BnVeDUFVBGgt7OKzDZILi+NMzFLP4WKiB /n9rYAobaDLX01SFxoDZL6gZVkj3ukciNAr/Ctm3TPX9ZBkUK2OyqDEar647XxbJUKLTFu1Hb dO+rUeLw1GvDTkjCMJqWKCGY69Tun2ST/EpCSR4ZhHiyb3oFeYH2w4C6G4arYssqHhT/OB2kh P0J3cFD5fIwNZ4iqcXrcEI0ytM5HXkkzzrSI+/uzTVmBXuvetwPDzPXUWQ3BhgwYiFavMfkuT z+b46AtrRDtvbj0RDFRlkc3DFuutWONgCFmzxY9K5YJenzjYZ0u7LTxWE/xre4O6OLdkEaFFi laUvtad1/MwgCwkwsPih8PEvQMcfW3kZw3hISsye7koVjIxZ1wVKPJyaES1yt+yntwlE3qEJ6 r7AhhCO4cz4rDSDMnjefhHmeFJ9pU0Pb3l4VCVqRtBuUY4PbDibshG30vvhugGw3etkVvG3jI OovmDiBnYdLO9/0oE6Y3LFJGHdURs9hFRqdmaDbGDd/FqRCqY9CsuzUpoZpnb8lJEsSk2l3FU kDlE+IIQ1Y+GcegVCucCsFjPbmwGw7QN7AxkUc3csQoJue134oShcFM9CUmeUVJeQYKxm9Xcs UazpL9KIPfxjFxgJiJFG737jeYRHzVkMr+auvjQQ9FGwwPU0njhI40fbbvHhXLsryweDTofgV T+mGT+LC/mQ5+VZnB5kg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On little-endian 32-bit application running on 64-bit kernels, the current vdso would read the wrong half of the xtime seconds field. Change it to return the lower half like it does on big-endian. Signed-off-by: Arnd Bergmann --- arch/powerpc/kernel/vdso32/gettimeofday.S | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.20.0 diff --git a/arch/powerpc/kernel/vdso32/gettimeofday.S b/arch/powerpc/kernel/vdso32/gettimeofday.S index becd9f8767ed..4327665ad86f 100644 --- a/arch/powerpc/kernel/vdso32/gettimeofday.S +++ b/arch/powerpc/kernel/vdso32/gettimeofday.S @@ -13,7 +13,7 @@ #include /* Offset for the low 32-bit part of a field of long type */ -#ifdef CONFIG_PPC64 +#if defined(CONFIG_PPC64) && defined(CONFIG_CPU_BIG_ENDIAN) #define LOPART 4 #define TSPEC_TV_SEC TSPC64_TV_SEC+LOPART #else From patchwork Fri Nov 8 20:34:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178956 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3245394ilf; Fri, 8 Nov 2019 12:36:22 -0800 (PST) X-Google-Smtp-Source: APXvYqyvVWaJornQLuHXJ1yvnD547ZOL7Jmo1+JWSSs2L+xvpkhrbpIUdmaKmhr5ksV2Vtnbi10d X-Received: by 2002:a17:906:52c4:: with SMTP id w4mr9786423ejn.99.1573245382239; Fri, 08 Nov 2019 12:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573245382; cv=none; d=google.com; s=arc-20160816; b=XKXl5E+zaW+JHpGfS/ockuKDDq5+TT3TrGowxHPmUDVjT2cLeKIDCSVCEQAZfasgXE V65y57sx7Cq25T2fXmuevLGqFLosiMbmQdRZvZJeKhIBDZ9nqisEVvBriu9ZygpVM3/W 1Z6RLjqAI7we70Ve+dxeFliA/7najYQzwkVBmfpsw+NDr0hYeNJHptsQM5GJPB81JHQl 3PzBSO4zlkkAuGmr5OgdxxUV1u9B8PI714/gzxDn+KeAhA3IcKxaRbsBwveQpE8KOr/B PL0LFvpD/FOLkY8fnaQ5e8QU4uK8P7PbgrZNGsUXmyEqdYkEGzOmSMCdq+0Rd3UPSgGT /jqw== 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; bh=lTwlL6UTv3w6PPy2PU/pmLBX5Tt3HdqSKCsb19DB07w=; b=IVFEXVuJRGNggwLUjNsEANxwkDAa7aniiXNFqacULHzPCioIdF6yTcb8zPmgIzQkiR nwaZfwi9SbIzltE94g/nIUxFIGJAgv/mOedPEwjZpZ+N67DTc3ZNc9wM8Vgznq9aGQ0a R2NYGWQmfQRu5vputHW79C/dAlM7pjAZ6cUOqVqzcVMwZ1vpd3Gy6pvHwpFFeFIIlAq/ uIFW8rZjoffGRDb/pryo8GMPG3aEkjPA17JphdEnzAlhqIvQdlnyY63R6n6X8LWQFJ0t QfLLVtBjf+iPNnCy0aiY5L+Rtf3Db+uYMuhncqGuWredFkWn7FsSE7vgUHIJVqQlCA47 zQkA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dd5si4572508ejb.179.2019.11.08.12.36.22; Fri, 08 Nov 2019 12:36:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732130AbfKHUgS (ORCPT + 26 others); Fri, 8 Nov 2019 15:36:18 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:52967 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbfKHUgS (ORCPT ); Fri, 8 Nov 2019 15:36:18 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1N7yuz-1hpfJe1Cz5-014yOw; Fri, 08 Nov 2019 21:35:57 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Corey Minyard , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, Corey Minyard , openipmi-developer@lists.sourceforge.net Subject: [PATCH 4/8] ipmi: kill off 'timespec' usage again Date: Fri, 8 Nov 2019 21:34:27 +0100 Message-Id: <20191108203435.112759-5-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108203435.112759-1-arnd@arndb.de> References: <20191108203435.112759-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:5h5zjTJTFS7NU7dR3OxD3RGZD81MiMNfiSZHg3//WQd5cEspSJc LIApSfiSz9Te28wkEE3ctR6BIBgRSUZv+L8WoFHniGGNul2rk23RWvU9J1joypQooUlQ9/Y DGmmNTguceLb02Y1evbVHD9ZTU8F11CtM7iKaUrqM2+zVzRGt7fUWskVkjFrWQxFHRWNCDP Wk8+4Q6wKeQ6K8pK07LrA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:TcWOuYfgQ1c=:5rJazEAWe8fZzBgGo5S7kS vEWFdfZBBTUpkp+pnxRlr2kLO4coolsU4UPvtSI/uWs6ncs2JIzQNkPtmpnxkSNYqY4aluw1Q +WUFzBe0iTFJFKK3OGgLW//tPpefDApoosfIVPfo6ZqSCOyaCypL59y8vqDdr/WVrpBtdN37d odZGiMdY5BAPDC5mMpXRE3MShieMhVrCIMBrJ+1qfeGSLSNZp3v2Wpm73FJeTVztusApsgWh1 uVoMimJy7Hy3SiRv1FRWJrpeZ03G/WVodq3+zpnppq47d2x8WwuKbyAsOm9Lj/kKsIoLjUzF6 +E3JzqvTv/oEMEK3MMvyHK8dnFvwAgm3RBGKlDRVJw63T+HnP33YXm1rs5oo1o+7rrLAqJlep NfRtxeJ3aShvYjGwpd3WB5Q92YPyB1Dqu81MtAgh0pAOlDImOXcdSVSuuVzqP7MqqiYE++mue CWV6DkqUrt5stJvHGqX9unK2mFM8Ga2ukfxYgB2YE4KqpS9LBpCw0RvWlI6CRLyZEiBIqiJbn A0bs+MvnRh37jz1HsGtAXmFM01joN1dktLIurvpV9iBgaeusR6eSNg9ixohYBwRVtUEs/pBnk BdD8VFtif50YujggMHE6LqfQIqaBEBn8XIVhFhgolWqn4nZOyjx4m0cmTF7vv2R+8MeVGQ1yI fQ7g5IH0MGfIK2GnlcSeTTSo88dcMo83TyzJmhrXvQoHTYIdOsX1S5RK+nHQWsXzdNF/LILJq GqeI0NScCQSLY1bZhOGnhhafLyEiMv65GDYeYBdU2+lsuX8kew1uHY61pmcRpmKVwydWkjvuZ IMn9bi1scc/juK2D5DpZRKZTlm8qjQ1TxO3kLdowUbQAO0ufELXvrEh50YL25ros262CVd7Pt 97v5Wkz54JcwT1EXeUGw== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'struct timespec' is getting removed from the kernel. The usage in ipmi was fixed before in commit 48862ea2ce86 ("ipmi: Update timespec usage to timespec64"), but unfortunately it crept back in. The busy looping code can better use ktime_t anyway, so use that there to simplify the implementation. Fixes: cbb19cb1eef0 ("ipmi_si: Convert timespec64 to timespec") Signed-off-by: Arnd Bergmann --- drivers/char/ipmi/ipmi_si_intf.c | 40 +++++++++++--------------------- 1 file changed, 13 insertions(+), 27 deletions(-) -- 2.20.0 Reviewed-by: Corey Minyard diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 6b9a0593d2eb..c7cc8538b84a 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -265,10 +265,10 @@ static void cleanup_ipmi_si(void); #ifdef DEBUG_TIMING void debug_timestamp(char *msg) { - struct timespec t; + struct timespec64 t; - ktime_get_ts(&t); - pr_debug("**%s: %ld.%9.9ld\n", msg, (long) t.tv_sec, t.tv_nsec); + ktime_get_ts64(&t); + pr_debug("**%s: %lld.%9.9ld\n", msg, t.tv_sec, t.tv_nsec); } #else #define debug_timestamp(x) @@ -935,38 +935,25 @@ static void set_run_to_completion(void *send_info, bool i_run_to_completion) } /* - * Use -1 in the nsec value of the busy waiting timespec to tell that - * we are spinning in kipmid looking for something and not delaying - * between checks + * Use -1 as a special constant to tell that we are spinning in kipmid + * looking for something and not delaying between checks */ -static inline void ipmi_si_set_not_busy(struct timespec *ts) -{ - ts->tv_nsec = -1; -} -static inline int ipmi_si_is_busy(struct timespec *ts) -{ - return ts->tv_nsec != -1; -} - +#define IPMI_TIME_NOT_BUSY ns_to_ktime(-1ull) static inline bool ipmi_thread_busy_wait(enum si_sm_result smi_result, const struct smi_info *smi_info, - struct timespec *busy_until) + ktime_t *busy_until) { unsigned int max_busy_us = 0; if (smi_info->si_num < num_max_busy_us) max_busy_us = kipmid_max_busy_us[smi_info->si_num]; if (max_busy_us == 0 || smi_result != SI_SM_CALL_WITH_DELAY) - ipmi_si_set_not_busy(busy_until); - else if (!ipmi_si_is_busy(busy_until)) { - ktime_get_ts(busy_until); - timespec_add_ns(busy_until, max_busy_us * NSEC_PER_USEC); + *busy_until = IPMI_TIME_NOT_BUSY; + else if (*busy_until == IPMI_TIME_NOT_BUSY) { + *busy_until = ktime_get() + max_busy_us * NSEC_PER_USEC; } else { - struct timespec now; - - ktime_get_ts(&now); - if (unlikely(timespec_compare(&now, busy_until) > 0)) { - ipmi_si_set_not_busy(busy_until); + if (unlikely(ktime_get() > *busy_until)) { + *busy_until = IPMI_TIME_NOT_BUSY; return false; } } @@ -988,9 +975,8 @@ static int ipmi_thread(void *data) struct smi_info *smi_info = data; unsigned long flags; enum si_sm_result smi_result; - struct timespec busy_until = { 0, 0 }; + ktime_t busy_until = IPMI_TIME_NOT_BUSY; - ipmi_si_set_not_busy(&busy_until); set_user_nice(current, MAX_NICE); while (!kthread_should_stop()) { int busy_wait; From patchwork Fri Nov 8 20:34:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 178957 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp3245554ilf; Fri, 8 Nov 2019 12:36:32 -0800 (PST) X-Google-Smtp-Source: APXvYqxfkYxRdGgH+3OcUqSX//V699tcHeOcIvhcdQdqmPE26tQeT5MvTUV3X6uDIuo+5U03BNg0 X-Received: by 2002:a50:eb8b:: with SMTP id y11mr12933017edr.242.1573245392175; Fri, 08 Nov 2019 12:36:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573245392; cv=none; d=google.com; s=arc-20160816; b=RTDU4gS7xDWDw9xITaE1NaLHKgiRw80aeOxtLn/ORUja/Y81YAoGBDmW74cozpurji FNUiaM3ujGajyMW2IYlLB95H8Zs4k5zRpjx3xoAsO5gLnYWwEPm6vCgyngUrANVq2Niz eySBNjAUE/E++vSSrGVkg2qhYzIrDs0eVvHFoukjspy+1BbR64kEZAKiI9a2/0PfaXUB nTZGzHCtd3v/QjstKNqx4bTTVzZCcKoRype6IkjjQ34gmYCiBD7tuzFz1CmNooI/A5xO KEVhhhhuDU3lWlt6KyOxydP2RXe0GBRMAewYXbKDI2ZlpN/GSYzZfc47d4JY+K3mTlHU BR4g== 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; bh=nynAsltFtnRhJTUORiEQ7+rixQKYyUSrV9PRMIvIUow=; b=Lbb25QIJQ10erIDS6nT72gDWqKiteJLj7gR7WD8NOLqhB3BvlbSO2JW/T8wlAF1SzW VKbsGNuNF60nStUg2+qohvDgTQvUAyI4AqonKxnrRV8ESexGi2ITWYCI003l0alupToZ R1wru/VF8x51EdPqwRPiJLiirWPMecyVYO0Nxw7MfFhd9JhfmlsLfHBLUX2DQ6L1fhlJ xtpX8Wfl7titvxYJHywQ8bJQ3as56MiHGM3t6VFvLDUZKUqtR0Ztyj/WAGQmf9nCkZha A8VwVQg+/lUiEQ5swfx4rMoct+TSPjB9EeH2tbIsiZ6QVgvgltFCkF1UIS0/RZBROGH8 ZE2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dd5si4572508ejb.179.2019.11.08.12.36.31; Fri, 08 Nov 2019 12:36:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732329AbfKHUga (ORCPT + 26 others); Fri, 8 Nov 2019 15:36:30 -0500 Received: from mout.kundenserver.de ([217.72.192.74]:36201 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732171AbfKHUg3 (ORCPT ); Fri, 8 Nov 2019 15:36:29 -0500 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue107 [212.227.15.145]) with ESMTPA (Nemesis) id 1MEF87-1iadeR36H7-00AGgW; Fri, 08 Nov 2019 21:36:18 +0100 From: Arnd Bergmann To: y2038@lists.linaro.org, Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Eric Dumazet , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev@vger.kernel.org Subject: [PATCH 5/8] netfilter: xt_time: use time64_t Date: Fri, 8 Nov 2019 21:34:28 +0100 Message-Id: <20191108203435.112759-6-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20191108203435.112759-1-arnd@arndb.de> References: <20191108203435.112759-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:LAqgtMHpuHsHVqesPbRDDOnPbG3k3aIkl2ycNWLlt4hNWDe/h94 GNpZ9xbyyD7LXXBKIdA2s2/AdUHfbg0DIx01Kj4OMx3p5kvSqUbOebvbj/QnE7eakpz0lHv uN5N4Lbi3Ve2HiOXFaAex9XSmQCyebw9uVyDgEMXqAnhjjgfzDAXhsrlExb0jFUFKUWnK+D 4XcdXehRUk7EHSe1W5zeA== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:uTLnXhQlaoA=:6gkTKIzGkH8u4p9n9EzB5+ lrHh5mqs0gNbpufpMED1aZFRj6EM8Vdvk21VmgHmavXEMmYc2wxSYeavDcGdpdZ7CadtsRnAO qsbfYORBBYZdz02Y0pFnzClpTjdJxDYOiPorKaYrirT28tLfMyelNHuTue4mitFpPQkwUJ2vp 1FdPn/cyPCua8wGrtCyi9289PPkzr214fg0Fv+WOBBWFYibuPoFVWzXyI83DcKdtvvPnvqIDz wdprTdsC/ZkfYx1s1jMPDmmohjYlPkV8FnO3K6nxce9wT/3gnfnxHFHUeiCMMJA22LZs2nOvn OLypew6aJxfs20P57HiMNl93gEsT/ycbJ4slABRZ7SD+vI3RGS4lWKiSvlZ4ZZmiwnhqiqFF6 Fi/2Y9koVFyxao8U3z3LmwEw2d4k9EduaQb3mljAM4tskCgWqBzRabEsK+FQfK0VwMISD3IIW eKKPfoaXuB3AV6ejoIfIyfJQvB+avcI6HFn8HPjfm6LOHo9GWEk0eoUOa9jTziwzOGTcl+cD8 gcHV80qweuOKUQszTaHIGeyW8GHBB0VgQf7EVzpkJjjJF7Cxl4bJVh8XV/7vXbWIf9M7eiW7O mucjrJW1Dqc/K1zHhLFKmZyuNrarpADVQ5zsZZu9VmgOrOVksy4eAIJbaKozfWtrjPhTIEmlZ D0+GgCVexquumqnxI1GUzSo2LH4sTJm7GUM6VZ190VgN9woJKTRGsN+7Vw1Az+NSbFtjEehCe ApXUQOzEXIOlfr98kuJiFJt4keBc1XueRtApEJZ9SKiLF9K6Hg4vDTcxSG9OWPjl48mdsLGTh jn56Ebw8x8hxA5jYZEZPKd2MMV86gz8op0dpLqRShX5Ujbjw2cpu0anrthVv58jvg5/ELj2ro rymaqfVxE+cCH9UVrcxg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current xt_time driver suffers from the y2038 overflow on 32-bit architectures, when the time of day calculations break. Also, on both 32-bit and 64-bit architectures, there is a problem with info->date_start/stop, which is part of the user ABI and overflows in in 2106. Fix the first issue by using time64_t and explicit calls to div_u64() and div_u64_rem(), and document the seconds issue. The explicit 64-bit division is unfortunately slower on 32-bit architectures, but doing it as unsigned lets us use the optimized division-through-multiplication path in most configurations. This should be fine, as the code already does not allow any negative time of day values. Using u32 seconds values consistently would probably also work and be a little more efficient, but that doesn't feel right as it would propagate the y2106 overflow to more place rather than fewer. Signed-off-by: Arnd Bergmann --- net/netfilter/xt_time.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) -- 2.20.0 diff --git a/net/netfilter/xt_time.c b/net/netfilter/xt_time.c index 8dbb4d48f2ed..67cb98489415 100644 --- a/net/netfilter/xt_time.c +++ b/net/netfilter/xt_time.c @@ -77,12 +77,12 @@ static inline bool is_leap(unsigned int y) * This is done in three separate functions so that the most expensive * calculations are done last, in case a "simple match" can be found earlier. */ -static inline unsigned int localtime_1(struct xtm *r, time_t time) +static inline unsigned int localtime_1(struct xtm *r, time64_t time) { unsigned int v, w; /* Each day has 86400s, so finding the hour/minute is actually easy. */ - v = time % SECONDS_PER_DAY; + div_u64_rem(time, SECONDS_PER_DAY, &v); r->second = v % 60; w = v / 60; r->minute = w % 60; @@ -90,13 +90,13 @@ static inline unsigned int localtime_1(struct xtm *r, time_t time) return v; } -static inline void localtime_2(struct xtm *r, time_t time) +static inline void localtime_2(struct xtm *r, time64_t time) { /* * Here comes the rest (weekday, monthday). First, divide the SSTE * by seconds-per-day to get the number of _days_ since the epoch. */ - r->dse = time / 86400; + r->dse = div_u64(time, SECONDS_PER_DAY); /* * 1970-01-01 (w=0) was a Thursday (4). @@ -105,7 +105,7 @@ static inline void localtime_2(struct xtm *r, time_t time) r->weekday = (4 + r->dse - 1) % 7 + 1; } -static void localtime_3(struct xtm *r, time_t time) +static void localtime_3(struct xtm *r, time64_t time) { unsigned int year, i, w = r->dse; @@ -160,7 +160,7 @@ time_mt(const struct sk_buff *skb, struct xt_action_param *par) const struct xt_time_info *info = par->matchinfo; unsigned int packet_time; struct xtm current_time; - s64 stamp; + time64_t stamp; /* * We need real time here, but we can neither use skb->tstamp @@ -173,14 +173,14 @@ time_mt(const struct sk_buff *skb, struct xt_action_param *par) * 1. match before 13:00 * 2. match after 13:00 * - * If you match against processing time (get_seconds) it + * If you match against processing time (ktime_get_real_seconds) it * may happen that the same packet matches both rules if * it arrived at the right moment before 13:00, so it would be * better to check skb->tstamp and set it via __net_timestamp() * if needed. This however breaks outgoing packets tx timestamp, * and causes them to get delayed forever by fq packet scheduler. */ - stamp = get_seconds(); + stamp = ktime_get_real_seconds(); if (info->flags & XT_TIME_LOCAL_TZ) /* Adjust for local timezone */ @@ -193,6 +193,9 @@ time_mt(const struct sk_buff *skb, struct xt_action_param *par) * - 'now' is in the weekday mask * - 'now' is in the daytime range time_start..time_end * (and by default, libxt_time will set these so as to match) + * + * note: info->date_start/stop are unsigned 32-bit values that + * can hold values beyond y2038, but not after y2106. */ if (stamp < info->date_start || stamp > info->date_stop)