Received: by 10.223.164.221 with SMTP id h29csp3202467wrb; Fri, 3 Nov 2017 03:29:53 -0700 (PDT) X-Google-Smtp-Source: ABhQp+SztgePilYSlC0kBb1yHtXCPSYjhEvlKJkdNSt7PTQMaILQR5O7resuvQ+STyYn6SaLVEcH X-Received: by 10.98.12.212 with SMTP id 81mr7220413pfm.88.1509704993875; Fri, 03 Nov 2017 03:29:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509704993; cv=none; d=google.com; s=arc-20160816; b=rMvihjAP5TRAE9Mk8UdVcTwJ+vmN6USX/WW76xIem82Mz16MURAIZzmbkEWA5trC91 nMGTAybXXlJ7lWkRoko9rj+4PVozCDiLBoNDO084wWqx8B1Uo2Wsm3xLVhDc00fVsBPA J/LKToLJpIdcyDQuYZhOI1+k/xj7izeRG/KGUX2yIH+MHEYJ/YYiuryZkOV93qjNf9Kd gV+zeitSVEi9dbkRUhZD7uCgk56M2LtpGudRjczb6sVOWxKvn6F+9HERhC8ls8P6D9Ic MzGhODZUAGj4vd4DM8jC6Rovz5XfaXTVV/7iIGoPxQAvC9S/WptI8fhT4U2ZuKwDY1u2 CgJg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=oML94/HDO1HUjdlNcuxdsTlgGvQJsd/B+qslhzbHR+Y=; b=aPnfpYOn8YCkfc0FaxRv/MeZUnoGpcSS5cO4JYxITQSkXVJCWK2nisUVaq/P5EwZkD ajV7mE0vOSCJtvuB0vu8XhbNH7otraLXvxP2ggn8Syq85jhTb7xCX7rxWukXWUBO1wGk eI4L7mntrjdC4q/oJotLKrVMhzSRGsuDDMNlnnrBFsu0d3VNN53Ya/tILJVw2hU6oT08 4BJw8uBHhQQ6GF8ifxmMsn05I83v/HB/ElxJ8/GqLVa+KO95gHKjd23KXornRCRNpjOg 9KdWnHKmgsGZsTZTALzfq9lOJvgYjfeRToApcCQ2WzWlfyJoWCuxrQklcgm8htqI5/CG HlPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=pOBc4kRS; 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 l24si6013226pfi.284.2017.11.03.03.29.40; Fri, 03 Nov 2017 03:29:53 -0700 (PDT) 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; dkim=pass header.i=@nexus-software-ie.20150623.gappssmtp.com header.s=20150623 header.b=pOBc4kRS; 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 S1755947AbdKCK2x (ORCPT + 97 others); Fri, 3 Nov 2017 06:28:53 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:46015 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755833AbdKCK2u (ORCPT ); Fri, 3 Nov 2017 06:28:50 -0400 Received: by mail-wm0-f68.google.com with SMTP id y80so514214wmd.0 for ; Fri, 03 Nov 2017 03:28:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nexus-software-ie.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=oML94/HDO1HUjdlNcuxdsTlgGvQJsd/B+qslhzbHR+Y=; b=pOBc4kRSlSxSwZhLRxj8U/CSA9h84CaCJnM0Qe/i5W97woF/Plp5XR37qQOKxHisEm FL4jDw28S7McCPuwmXDBGODr9c7gH5REj8kVlUWS+L4QjADoJRuU3hPKXLEjPrT/AC2F BXwbP3mxJrMdFdRLEN30mYZgo+jS3W0YjwKCUDc6mzCHpT3z7Hqlb4BWfJ6qPkAtrUSM TqB66Mwy8UBfmVAcURyaYF9klolDoyLzBSLe5z3y8Sd9DxpZ2AqSXWhpFQnJ76zT1+6v OoyCKNxEpqwKuoYwtT72yKvSqgCvxiHCGPEAaEUDltK9FXY0+w3mZ4miOMngjHgYILQR EgLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oML94/HDO1HUjdlNcuxdsTlgGvQJsd/B+qslhzbHR+Y=; b=gd1Tfp8WB7D8p90gOLITO2zf4c6Xrjc0Ode+UqeoTVe4LQ1ppoZ9UXvh06PjbBnZIs WTML1j0eC6vy4hw5nSm7cV4aTBjLq+dc15rEjYZheDW3h1ywJ2nZMgukZwxNlzhZfTyq BEOFfcjhQDNrUMNRc7V4DaC251J2vWy/pL8F1moI0rdf6N4BBxJXhQcTJFguJmJ25BOx Jm8jIrqkO6Yo8xFnPv4A7qZX1m4R/FKH3tQCi0cqfEGovOAqSeHF9bFd/KFmJgVz/9mY mg/cmiC4Lu9beWFzkVwBIYoujapS/GwtR3GFUbCetpl1SZfbRJsXV3O9l0mI5C4UgSza a9iA== X-Gm-Message-State: AMCzsaXBSYM3UY2OXVhZNEQ9E7KTuqyztUo+4eBDUt54ZaMYYGBpHKYb wnXRaon+cjJDmX1gnF03BEkn4DfxllE= X-Received: by 10.80.158.194 with SMTP id a60mr8352249edf.182.1509704928837; Fri, 03 Nov 2017 03:28:48 -0700 (PDT) Received: from [192.168.192.35] ([109.255.42.2]) by smtp.gmail.com with ESMTPSA id m8sm5312471edl.74.2017.11.03.03.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Nov 2017 03:28:48 -0700 (PDT) Subject: Re: [PATCH 2/2] staging: greybus/loopback: use ktime_get() for time intervals To: Arnd Bergmann , Johan Hovold , Alex Elder , Greg Kroah-Hartman Cc: Gioh Kim , Abdul Rauf , Arushi Singhal , greybus-dev@lists.linaro.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org References: <20171102143304.851481-1-arnd@arndb.de> <20171102143304.851481-2-arnd@arndb.de> From: Bryan O'Donoghue Message-ID: <61965985-d5c3-c231-1d18-5d14b1ce7b2d@nexus-software.ie> Date: Fri, 3 Nov 2017 10:28:47 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.1 MIME-Version: 1.0 In-Reply-To: <20171102143304.851481-2-arnd@arndb.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/11/17 14:32, Arnd Bergmann wrote: > This driver is the only one using the deprecated timeval_to_ns() > helper. Changing it from do_gettimeofday() to ktime_get() makes > the code more efficient, more robust against concurrent > settimeofday(), more accurate and lets us get rid of that helper > in the future. > > Signed-off-by: Arnd Bergmann > --- > drivers/staging/greybus/loopback.c | 42 ++++++++++++++++---------------------- > 1 file changed, 18 insertions(+), 24 deletions(-) > > diff --git a/drivers/staging/greybus/loopback.c b/drivers/staging/greybus/loopback.c > index 85046fb16aad..3d92638c424b 100644 > --- a/drivers/staging/greybus/loopback.c > +++ b/drivers/staging/greybus/loopback.c > @@ -58,7 +58,7 @@ static struct gb_loopback_device gb_dev; > struct gb_loopback_async_operation { > struct gb_loopback *gb; > struct gb_operation *operation; > - struct timeval ts; > + ktime_t ts; > struct timer_list timer; > struct list_head entry; > struct work_struct work; > @@ -81,7 +81,7 @@ struct gb_loopback { > atomic_t outstanding_operations; > > /* Per connection stats */ > - struct timeval ts; > + ktime_t ts; > struct gb_loopback_stats latency; > struct gb_loopback_stats throughput; > struct gb_loopback_stats requests_per_second; > @@ -375,14 +375,9 @@ static u64 __gb_loopback_calc_latency(u64 t1, u64 t2) > return NSEC_PER_DAY - t2 + t1; > } > > -static u64 gb_loopback_calc_latency(struct timeval *ts, struct timeval *te) > +static u64 gb_loopback_calc_latency(ktime_t ts, ktime_t te) > { > - u64 t1, t2; > - > - t1 = timeval_to_ns(ts); > - t2 = timeval_to_ns(te); > - > - return __gb_loopback_calc_latency(t1, t2); > + return __gb_loopback_calc_latency(ktime_to_ns(ts), ktime_to_ns(te)); > } > > static int gb_loopback_operation_sync(struct gb_loopback *gb, int type, > @@ -390,10 +385,10 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type, > void *response, int response_size) > { > struct gb_operation *operation; > - struct timeval ts, te; > + ktime_t ts, te; > int ret; > > - do_gettimeofday(&ts); > + ts = ktime_get(); > operation = gb_operation_create(gb->connection, type, request_size, > response_size, GFP_KERNEL); > if (!operation) > @@ -421,10 +416,10 @@ static int gb_loopback_operation_sync(struct gb_loopback *gb, int type, > } > } > > - do_gettimeofday(&te); > + te = ktime_get(); > > /* Calculate the total time the message took */ > - gb->elapsed_nsecs = gb_loopback_calc_latency(&ts, &te); > + gb->elapsed_nsecs = gb_loopback_calc_latency(ts, te); > > out_put_operation: > gb_operation_put(operation); > @@ -492,10 +487,10 @@ static void gb_loopback_async_operation_callback(struct gb_operation *operation) > { > struct gb_loopback_async_operation *op_async; > struct gb_loopback *gb; > - struct timeval te; > + ktime_t te; > bool err = false; > > - do_gettimeofday(&te); > + te = ktime_get(); > op_async = gb_loopback_operation_find(operation->id); > if (!op_async) > return; > @@ -512,8 +507,7 @@ static void gb_loopback_async_operation_callback(struct gb_operation *operation) > } > > if (!err) > - gb->elapsed_nsecs = gb_loopback_calc_latency(&op_async->ts, > - &te); > + gb->elapsed_nsecs = gb_loopback_calc_latency(op_async->ts, te); > > if (op_async->pending) { > if (err) > @@ -608,7 +602,7 @@ static int gb_loopback_async_operation(struct gb_loopback *gb, int type, > list_add_tail(&op_async->entry, &gb_dev.list_op_async); > spin_unlock_irqrestore(&gb_dev.lock, flags); > > - do_gettimeofday(&op_async->ts); > + op_async->ts = ktime_get(); > op_async->pending = true; > atomic_inc(&gb->outstanding_operations); > mutex_lock(&gb->mutex); > @@ -842,7 +836,7 @@ static void gb_loopback_reset_stats(struct gb_loopback *gb) > /* Should be initialized at least once per transaction set */ > gb->apbridge_latency_ts = 0; > gb->gbphy_latency_ts = 0; > - memset(&gb->ts, 0, sizeof(struct timeval)); > + gb->ts = ktime_set(0, 0); > } > > static void gb_loopback_update_stats(struct gb_loopback_stats *stats, u32 val) > @@ -925,15 +919,15 @@ static void gb_loopback_calculate_stats(struct gb_loopback *gb, bool error) > { > u64 nlat; > u32 lat; > - struct timeval te; > + ktime_t te; > > if (!error) { > gb->requests_completed++; > gb_loopback_calculate_latency_stats(gb); > } > > - do_gettimeofday(&te); > - nlat = gb_loopback_calc_latency(&gb->ts, &te); > + te = ktime_get(); > + nlat = gb_loopback_calc_latency(gb->ts, te); > if (nlat >= NSEC_PER_SEC || gb->iteration_count == gb->iteration_max) { > lat = gb_loopback_nsec_to_usec_latency(nlat); > > @@ -1017,8 +1011,8 @@ static int gb_loopback_fn(void *data) > size = gb->size; > us_wait = gb->us_wait; > type = gb->type; > - if (gb->ts.tv_usec == 0 && gb->ts.tv_sec == 0) > - do_gettimeofday(&gb->ts); > + if (ktime_to_ns(gb->ts) == 0) > + gb->ts = ktime_get(); > mutex_unlock(&gb->mutex); > > /* Else operations to perform */ > This one I'd like to test first. I'll get back to you From 1583015890295244269@xxx Fri Nov 03 03:59:57 +0000 2017 X-GM-THRID: 1582965273835454342 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread