From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 308DFC4332F for ; Fri, 4 Nov 2022 09:04:46 +0000 (UTC) Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.96) (envelope-from ) id 1oqsco-0007Ov-0X; Fri, 04 Nov 2022 05:04:30 -0400 Received: from mscreen.etri.re.kr ([129.254.9.16]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA (Exim 4.96) (envelope-from ) id 1oqsck-0007Od-1E for kernelnewbies@kernelnewbies.org; Fri, 04 Nov 2022 05:04:27 -0400 Received: from unknown (HELO send002-relay.gov-dooray.com) (211.180.235.153) by 129.254.9.16 with ESMTP; 4 Nov 2022 18:04:17 +0900 X-Original-SENDERIP: 211.180.235.153 X-Original-MAILFROM: ckim@etri.re.kr X-Original-RCPTTO: kernelnewbies@kernelnewbies.org Received: from [10.162.225.112] (HELO smtp002-imp.gov-dooray.com) ([10.162.225.112]) by send002-relay.gov-dooray.com with SMTP id f91f114a6364d591; Fri, 04 Nov 2022 18:04:17 +0900 DKIM-Signature: a=rsa-sha256; b=wzpMy/Y2CNErZyMARrSHcalfRidMrrFo73ETRIJypLwYY01iKxzwQ/4mvc/R0eU5m/KH1pwCS5 jrrDmjS81vAYsfjEdEGNzTahJCwW7I3cPxZV22TiKQwgo/3PYGwko6bwgUCysl0DqWDHKIYYn+2M ezGQ6n2IrIrqUeAPF4pD07iVzutC5g7Q1TfkWsmz7aLTiHcNCMmQm2QIOpAOxR5CVOwMw4na1Dhr I5Vtw++4Hp/iOwgdVFlfsD0s7km7CWGsIRb7Oipf5WJ1HFY4fIiUu7JzbDW4PwomJ3hjaCYo6QQp Z0E4tmxfPuZBzsELynr2mDifRUjeQi42VLZ+iUBA==; c=relaxed/relaxed; s=selector; d=dooray.com; v=1; bh=x6jT8aDwn9WRGa2OzLCXaFKXNm1JBDWZYQTjJ7OYH14=; h=From:To:Subject:Message-ID; Received: from [129.254.132.39] (HELO CHANKIMPC) ([129.254.132.39]) by smtp002-imp.gov-dooray.com with SMTP id 2020dbc46364d590; Fri, 04 Nov 2022 18:04:17 +0900 From: "Chan Kim" To: Subject: clock_gettime function doesn't scale to real time.. and changing CNTFRQ_EL0 doesn't make any change..(arm64) Date: Fri, 4 Nov 2022 18:04:15 +0900 Message-ID: <143801d8f02c$6a126f90$3e374eb0$@etri.re.kr> MIME-Version: 1.0 X-Mailer: Microsoft Outlook 16.0 Content-Language: ko Thread-Index: AdjwLGlx4LU9/bZ0QDW8LeOKu6/U0Q== X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============5220264317233837191==" Errors-To: kernelnewbies-bounces@kernelnewbies.org This is a multipart message in MIME format. --===============5220264317233837191== Content-Type: multipart/alternative; boundary="----=_NextPart_000_1439_01D8F077.D9FA8CC0" Content-Language: ko This is a multipart message in MIME format. ------=_NextPart_000_1439_01D8F077.D9FA8CC0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hello linux experts and newbies, I have ported linux on our arm64 fpga board. Both 5.10.0 and 5.15.xx works ok with minimal config. I have run a simple application and timed the processing time using clock_gettime function. It felt like it took almost 2.3 seconds but the program say it took only 0.36 seconds. Here is how I did it in the application. Int main() { struct timespec start, stop; float exec_time_sec, exec_time_nsec; //check start time if (clock_gettime(CLOCK_REALTIME, &start) == -1 ) { perror ("clock_gettime"); exit(EXIT_FAILURE); } Do something... (calculate fibonacci value for 1 ~ 30) //check end time if (clock_gettime(CLOCK_REALTIME, &stop) == -1 ) { perror ("clock_gettime"); exit(EXIT_FAILURE); } //Normalize to mili second exec_time_sec = (float)(stop.tv_sec - start.tv_sec); exec_time_nsec = (float)((double)(stop.tv_nsec - start.tv_nsec)/(double)BILLION); printf("Execution time : %f sec\n", exec_time_sec + exec_time_nsec); return 0; } I used u-boot program for loading linux kernel and the u-boot program sets the CNTFRQ_EL0 register with 5000000. (which is 5MHz, I heard the system clock runs at 5MHz in the board). The description of the register in armv8 arch manual says : This register is provided so that software can discover the frequency of the system counter. It must be programmed with this value as part of system initialization. The value of the register is not interpreted by hardware. I tried setting the CNTFRQ_EL0 with 20Mhz, expecting the execution to be displayed 4 times shorter but it is the same! I couldn't find how linux uses clock_gettime. How can I solve this problem? Any advice will be deeply appreciated. Thank you! Chan Kim ------=_NextPart_000_1439_01D8F077.D9FA8CC0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable clock_gettime function doesn't scale to real time.. and changing = CNTFRQ_EL0 doesn't make any change..(arm64)

Hello linux experts and newbies,

I have ported linux on our arm64 fpga board. Both 5.10.0 and 5.15.xx = works ok with = minimal config.

I have run a simple = application and timed the processing time using clock_gettime function.

It felt like it took almost 2.3 seconds but the = program say it took only 0.36 seconds.

Here is how I did  = it in the application.

    Int main() {

    struct timespec start, stop;

        float exec_time_sec, = exec_time_nsec;

    //check start time

        if (clock_gettime(CLOCK_REALTIME, &start) = =3D=3D -1 )  {

            perror = ("clock_gettime");

            exit(EXIT_FAILURE);

        }

    Do something... (calculate fibonacci value = for 1 ~ 30)

    //check end time

        if (clock_gettime(CLOCK_REALTIME, &stop) = =3D=3D -1 )  {

            perror = ("clock_gettime");

            = exit(EXIT_FAILURE);

        }

        //Normalize to mili second

        exec_time_sec =3D (float)(stop.tv_sec - = start.tv_sec);

        exec_time_nsec =3D (float)((double)(stop.tv_nsec = - start.tv_nsec)/(double)BILLION);

        printf("Execution time : %f sec\n", exec_time_sec + = exec_time_nsec);

    return 0;

    }

I = used u-boot program for = loading linux kernel = and the u-boot program sets the CNTFRQ_EL0 register with = 5000000.

(which is 5MHz, I heard = the system clock runs at 5MHz = in the board).

The description of = the register in armv8 arch = manual says :

This register is provided so that software = can discover the frequency of the system counter. It = must

be programmed with this value as part of = system initialization. The value of the register is = not

interpreted by hardware.

I tried setting the CNTFRQ_EL0 with 20Mhz, expecting the execution to = be displayed 4 times = shorter but it is the = same!

I couldn't find how linux uses clock_gettime.

How can I solve this problem?

Any advice will be deeply = appreciated.

Thank you!

Chan Kim

------=_NextPart_000_1439_01D8F077.D9FA8CC0-- --===============5220264317233837191== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============5220264317233837191==--