Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp684250pxx; Wed, 28 Oct 2020 14:24:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwFwq4RNb/i7BIxiuqIa/b1/TJdsVdb9bC0po+YcjbKywzllNv+U0q6FxObtNGfSpobNBLm X-Received: by 2002:a17:906:8305:: with SMTP id j5mr1026352ejx.497.1603920296267; Wed, 28 Oct 2020 14:24:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603920296; cv=none; d=google.com; s=arc-20160816; b=e3XZKF5lBoVp7j06HYHVLnsUzONbzYVJLRQJMV8UaEJv3MM/l6i29a5SifY3LQskiw 1Un0oOFwLXdtMmiyqz7jqghFE8vEQ1HMeoBOKPzt9WsD1HL4qJSR9qRAi+JxbYxB/YWv ozWHzd4gcIk0I8gwOgZQOKXUH4je12NxAn1+BunF8giNlqTzuS8HltnGxF1Xnh4TdE+k Fo9RloQDkFqBJ/o9PIE2MIvuYUrSfTHe4iRQEvAuu7ikaVBUM92BVYpvvk+mHKngK92B IH6k5w/wFsSA72H+abMjBvP+5L3nO5eqMIbsePOwhRRAIbwkUWYggXepxwKzZqYnblHA 85Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :to:subject:dkim-signature; bh=4HIc/0MR2zHvdieD9zh6vgSLY8pbQbGIFImMryqW80s=; b=VLkQhTMu0X0tfq8/g0W5V5Mb+KbFCfzBL2Xoh1f8LrgkXmNznE/1BCnHXoms/IFpoW U4neCacc9lMaoNv+zuGSHKydoulTp1hTx0ioSxBlZeL9EEoz6p3G1O2zLGqXdJf8jv1J /tesNS7AJbhxMcwL5Sfj8MeP78i6MdB9+aQS5TTpQWnEbhDoXt04gFJi9XtCaujqo7rO EO0QFRm56w/gg9Bwtjz8y52J7EKCTYNWGbpheougMfsYCS1nyxBLL0WXDuksH5HRyEpX rDIzpcYNjcZ6HPjaSPYUjr+ELL3f9syWuyKG1q5T+fHcZ5Jw6qANmlaKlgLYLVM0BvTc +vGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=PPPa3tmp; 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=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co4si129868edb.461.2020.10.28.14.24.33; Wed, 28 Oct 2020 14:24:56 -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=@linuxfoundation.org header.s=google header.b=PPPa3tmp; 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=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2504558AbgJ0UIf (ORCPT + 99 others); Tue, 27 Oct 2020 16:08:35 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:38909 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1830920AbgJ0UIe (ORCPT ); Tue, 27 Oct 2020 16:08:34 -0400 Received: by mail-io1-f65.google.com with SMTP id y20so2945296iod.5 for ; Tue, 27 Oct 2020 13:08:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=4HIc/0MR2zHvdieD9zh6vgSLY8pbQbGIFImMryqW80s=; b=PPPa3tmp2ks9hMD+/SvUol0Jx+R7oBCr+e32JI5nCuiG5v1h2ucr/FqTIkj9xsqVMk 82ZR0Ou9cOuG1rkvlK/33AXrWcAmuXcDoj7+Ax3tfPhEd4XOPHUE2JgiVGcHG2kAVp07 zvMESFRR7oZiOKXo8KvZpW4q9iZ9AgHen6rdI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=4HIc/0MR2zHvdieD9zh6vgSLY8pbQbGIFImMryqW80s=; b=ErrHCiqJrJRiKRcIJH5bOdp7WyB0zjGnQbwnZ8+Wps28kbp8iDA5yQ93csXn+gvTJj ByoM3kmbTnI+aa3VfvG+SDCvr4Lz7cRcvjNxJGgEz6OBKpXowToL24v3YKrBpcoVl6TS hxcu1ee8T08gW8TylGpD6lk0ERF27WiBwjxdd7SdRbwknGOU1VHGWJxe+mzFP2ltEGcs N60UCBegLTdXIQrI1CPUVh0oaejfJriTnH/YXUxQ7VDXs/km6Fi11+rfKe20DWwbC5+4 +aDS5uoDvjhwuUzQZsO+uM+/pDyNueSoTBcqPjpUrWUWZ8RbkgNbbX2SE/qGUQkDASvo EnKg== X-Gm-Message-State: AOAM532/lD9K6fAneqWiisDDvWRHlQqH55HQkORN3RSN1KhwsSHn71tI Sr+DGjxFcy/XaKLOUrMxEK16ZA== X-Received: by 2002:a6b:cf18:: with SMTP id o24mr3595316ioa.57.1603829313981; Tue, 27 Oct 2020 13:08:33 -0700 (PDT) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id r14sm1456512ilc.78.2020.10.27.13.08.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Oct 2020 13:08:33 -0700 (PDT) Subject: Re: [PATCH] selftests: intel_pstate: ftime() is deprecated To: Tommi Rantala , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan , Shuah Khan References: <20201016132245.73378-1-tommi.t.rantala@nokia.com> From: Shuah Khan Message-ID: Date: Tue, 27 Oct 2020 14:08:32 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201016132245.73378-1-tommi.t.rantala@nokia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tommi, On 10/16/20 7:22 AM, Tommi Rantala wrote: > Use clock_gettime() instead of deprecated ftime(). > > aperf.c: In function ‘main’: > aperf.c:58:2: warning: ‘ftime’ is deprecated [-Wdeprecated-declarations] > 58 | ftime(&before); > | ^~~~~ > In file included from aperf.c:9: > /usr/include/sys/timeb.h:39:12: note: declared here > 39 | extern int ftime (struct timeb *__timebuf) > | ^~~~~ > Thanks for the fix. One comment below > Signed-off-by: Tommi Rantala > --- > tools/testing/selftests/intel_pstate/aperf.c | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > > diff --git a/tools/testing/selftests/intel_pstate/aperf.c b/tools/testing/selftests/intel_pstate/aperf.c > index f6cd03a87493..eea9dbab459b 100644 > --- a/tools/testing/selftests/intel_pstate/aperf.c > +++ b/tools/testing/selftests/intel_pstate/aperf.c > @@ -10,6 +10,7 @@ > #include > #include > #include > +#include > #include "../kselftest.h" > > void usage(char *name) { > @@ -22,7 +23,7 @@ int main(int argc, char **argv) { > long long tsc, old_tsc, new_tsc; > long long aperf, old_aperf, new_aperf; > long long mperf, old_mperf, new_mperf; > - struct timeb before, after; > + struct timespec before, after; > long long int start, finish, total; > cpu_set_t cpuset; > > @@ -55,7 +56,10 @@ int main(int argc, char **argv) { > return 1; > } > > - ftime(&before); > + if (clock_gettime(CLOCK_MONOTONIC, &before) < 0) { > + perror("clock_gettime"); > + return 1; > + } > pread(fd, &old_tsc, sizeof(old_tsc), 0x10); > pread(fd, &old_aperf, sizeof(old_mperf), 0xe7); > pread(fd, &old_mperf, sizeof(old_aperf), 0xe8); > @@ -64,7 +68,10 @@ int main(int argc, char **argv) { > sqrt(i); > } > > - ftime(&after); > + if (clock_gettime(CLOCK_MONOTONIC, &after) < 0) { > + perror("clock_gettime"); > + return 1; > + } > pread(fd, &new_tsc, sizeof(new_tsc), 0x10); > pread(fd, &new_aperf, sizeof(new_mperf), 0xe7); > pread(fd, &new_mperf, sizeof(new_aperf), 0xe8); > @@ -73,8 +80,8 @@ int main(int argc, char **argv) { > aperf = new_aperf-old_aperf; > mperf = new_mperf-old_mperf; > > - start = before.time*1000 + before.millitm; > - finish = after.time*1000 + after.millitm; > + start = before.tv_sec*1000 + before.tv_nsec/1000000L; > + finish = after.tv_sec*1000 + after.tv_nsec/1000000L; Why not use timespec dNSEC_PER_MSEC define from include/vdso/time64.h? thanks, -- Shuah