From owner-svn-src-head@freebsd.org Fri Aug 4 06:40:44 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 09824DC9550 for ; Fri, 4 Aug 2017 06:40:44 +0000 (UTC) (envelope-from 0100015dabf98040-76cfbcc7-5de4-4e35-9a90-60fa54d31563-000000@amazonses.com) Received: from a8-237.smtp-out.amazonses.com (a8-237.smtp-out.amazonses.com [54.240.8.237]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id C26A38057B for ; Fri, 4 Aug 2017 06:40:43 +0000 (UTC) (envelope-from 0100015dabf98040-76cfbcc7-5de4-4e35-9a90-60fa54d31563-000000@amazonses.com) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=ae7m2yrxjw65l2cqdpjxuucyrvy564tn; d=tarsnap.com; t=1501828841; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=J8uQtE9lnLLaxxKHLhZHcnoZXRb134blpCUNBAfuQ/s=; b=ITH3jgb7QtFa9u/p8B/MxfR/LqXz53Fk7VsUsUPQW1X6vfwOkD06EZgIxd9I1v38 qQnYR/gNvkPC1RvA1/Pj2b8pHhI8yKZwbCXJNc1BIbA0wK0sz1dP7HaIeHIAqJRqNof tN0/08umh3m/uP970GaRC7iu0nB8tkRB0PVQHDLg= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/simple; s=224i4yxa5dv7c2xz3womw6peuasteono; d=amazonses.com; t=1501828841; h=Subject:To:References:Cc:From:Message-ID:Date:MIME-Version:In-Reply-To:Content-Type:Content-Transfer-Encoding:Feedback-ID; bh=J8uQtE9lnLLaxxKHLhZHcnoZXRb134blpCUNBAfuQ/s=; b=MrxqMh+oZB8p+HHZPCLXEgDwrRu68dUtkONcfZj4TFN2GLcWGHQjWr/DBODlQnfa YOY0WfFRdp+z3vrTlevhWatxCaP8MRG+2HWj3uMgPV7c+uewvYfiy0KH1ZeeQt+Wwdb +JdT3X3Q27TIJYvKY2HO6fqHf5C0iMWfjE/MqSkI= Subject: Re: svn commit: r321985 - head/sys/ofed/drivers/infiniband/core To: Hans Petter Selasky , cem@freebsd.org References: <201708030918.v739IPVY034866@repo.freebsd.org> Cc: src-committers , svn-src-all@freebsd.org, svn-src-head@freebsd.org From: Colin Percival Message-ID: <0100015dabf98040-76cfbcc7-5de4-4e35-9a90-60fa54d31563-000000@email.amazonses.com> Date: Fri, 4 Aug 2017 06:40:41 +0000 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SES-Outgoing: 2017.08.04-54.240.8.237 Feedback-ID: 1.us-east-1.Lv9FVjaNvvR5llaqfLoOVbo2VxOELl7cjN0AOyXnPlk=:AmazonSES X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Aug 2017 06:40:44 -0000 On 08/03/17 23:28, Hans Petter Selasky wrote: > On 08/03/17 16:37, Conrad Meyer wrote: >> Is it not important that the subtraction and result are evaluated >> without truncation? > > ticks is a circular counter. Assuming time = 0 and jiffies = -1U, then "delay" > becomes a very large negative value, because long is used, and the delay <= 0 > check, is no longer working like expected. > > Casting to "int" or truncating is the right thing to do in this case. Signed integer overflow is undefined. Using 'int' is liable to cause problems after 2^32 ticks. Colin Percival >>> Log: >>> Ticks are 32-bit in FreeBSD. >>> >>> MFC after: 3 days >>> Sponsored by: Mellanox Technologies >>> >>> Modified: >>> head/sys/ofed/drivers/infiniband/core/addr.c >>> >>> Modified: head/sys/ofed/drivers/infiniband/core/addr.c >>> ============================================================================== >>> --- head/sys/ofed/drivers/infiniband/core/addr.c Thu Aug 3 09:14:43 >>> 2017 (r321984) >>> +++ head/sys/ofed/drivers/infiniband/core/addr.c Thu Aug 3 09:18:25 >>> 2017 (r321985) >>> @@ -187,10 +187,10 @@ EXPORT_SYMBOL(rdma_translate_ip); >>> >>> static void set_timeout(unsigned long time) >>> { >>> - unsigned long delay; >>> + int delay; /* under FreeBSD ticks are 32-bit */ >>> >>> delay = time - jiffies; >>> - if ((long)delay <= 0) >>> + if (delay <= 0) >>> delay = 1; >>> >>> mod_delayed_work(addr_wq, &work, delay); -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid