Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S264302AbUFGFvv (ORCPT ); Mon, 7 Jun 2004 01:51:51 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S264298AbUFGFvv (ORCPT ); Mon, 7 Jun 2004 01:51:51 -0400 Received: from fmr06.intel.com ([134.134.136.7]:64236 "EHLO caduceus.jf.intel.com") by vger.kernel.org with ESMTP id S264302AbUFGFvb (ORCPT ); Mon, 7 Jun 2004 01:51:31 -0400 content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----_=_NextPart_001_01C44C53.6BBC45A6" X-MimeOLE: Produced By Microsoft Exchange V6.0.6487.1 Subject: RE: [PATCH] One possible bugfix for CLOCK_REALTIME timer. Date: Mon, 7 Jun 2004 13:51:04 +0800 Message-ID: <37FBBA5F3A361C41AB7CE44558C3448E045DD47F@PDSMSX403.ccr.corp.intel.com> X-MS-Has-Attach: yes X-MS-TNEF-Correlator: Thread-Topic: [PATCH] One possible bugfix for CLOCK_REALTIME timer. Thread-Index: AcRKsOBSEEKo/uFTTCCCYTnZ827ukwBof71Q From: "Hu, Boris" To: Cc: , "Li, Adam" , , "Hu, Boris" X-OriginalArrivalTime: 07 Jun 2004 05:51:05.0148 (UTC) FILETIME=[6C04FFC0:01C44C53] Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 22337 Lines: 477 This is a multi-part message in MIME format. ------_=_NextPart_001_01C44C53.6BBC45A6 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable One minor update according to your comments. Thanks. diff -urN -X dontdiff linux-2.6.6/include/linux/posix-timers.h linux-2.6.6.dev/include/linux/posix-timers.h --- linux-2.6.6/include/linux/posix-timers.h 2004-06-04 15:48:33.000000000 +0800 +++ linux-2.6.6.dev/include/linux/posix-timers.h 2004-06-04 10:40:10.000000000 +0800 @@ -1,9 +1,14 @@ #ifndef _linux_POSIX_TIMERS_H #define _linux_POSIX_TIMERS_H =20 +#include +#include + struct k_clock { int res; /* in nano seconds */ - int (*clock_set) (struct timespec * tp); + struct list_head abs_timer_list; + spinlock_t abs_timer_lock; + int (*clock_set) (struct timespec * tp); int (*clock_get) (struct timespec * tp); int (*nsleep) (int flags, struct timespec * new_setting, diff -urN -X dontdiff linux-2.6.6/include/linux/sched.h linux-2.6.6.dev/include/linux/sched.h --- linux-2.6.6/include/linux/sched.h 2004-06-04 15:48:33.000000000 +0800 +++ linux-2.6.6.dev/include/linux/sched.h 2004-06-04 10:39:53.000000000 +0800 @@ -342,6 +342,8 @@ struct task_struct *it_process; /* process to send signal to */ struct timer_list it_timer; struct sigqueue *sigq; /* signal queue entry. */ + struct list_head abs_timer_entry; /* clock abs_timer_list */ + struct timespec wall_to_monotonic_prev; }; =20 =20 diff -urN -X dontdiff linux-2.6.6/kernel/posix-timers.c linux-2.6.6.dev/kernel/posix-timers.c --- linux-2.6.6/kernel/posix-timers.c 2004-06-04 15:48:33.000000000 +0800 +++ linux-2.6.6.dev/kernel/posix-timers.c 2004-06-07 12:57:28.000000000 +0800 @@ -7,6 +7,9 @@ * * Copyright (C) 2002 2003 by MontaVista Software. * + * 2004-06-01 Fix CLOCK_REALTIME clock/timer TIMER_ABSTIME bug. + * Copyright (C) 2004 Boris Hu + * =20 * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at @@ -95,7 +98,7 @@ # define set_timer_inactive(tmr) \ do { \ (tmr)->it_timer.entry.prev =3D (void *)TIMER_INACTIVE; \ - } while (0) + } while (0) #else # define timer_active(tmr) BARFY // error to use outside of SMP # define set_timer_inactive(tmr) do { } while (0) @@ -200,7 +203,9 @@ */ static __init int init_posix_timers(void) { - struct k_clock clock_realtime =3D {.res =3D CLOCK_REALTIME_RES }; + struct k_clock clock_realtime =3D {.res =3D CLOCK_REALTIME_RES, + .abs_timer_lock =3D SPIN_LOCK_UNLOCKED + }; struct k_clock clock_monotonic =3D {.res =3D CLOCK_REALTIME_RES, .clock_get =3D do_posix_clock_monotonic_gettime, .clock_set =3D do_posix_clock_monotonic_settime @@ -212,7 +217,6 @@ posix_timers_cache =3D kmem_cache_create("posix_timers_cache", sizeof (struct k_itimer), 0, 0, 0, 0); idr_init(&posix_timers_id); - return 0; } =20 @@ -360,6 +364,11 @@ set_timer_inactive(timr); timer_notify_task(timr); unlock_timer(timr, flags); + if (CLOCK_REALTIME =3D=3D timr->it_clock) { + spin_lock(&posix_clocks[CLOCK_REALTIME].abs_timer_lock); + list_del_init(&timr->abs_timer_entry); + spin_unlock(&posix_clocks[CLOCK_REALTIME].abs_timer_lock); + } =20 } =20 =20 @@ -388,6 +397,7 @@ return; } posix_clocks[clock_id] =3D *new_clock; + INIT_LIST_HEAD(&posix_clocks[clock_id].abs_timer_list); } =20 static struct k_itimer * alloc_posix_timer(void) @@ -402,6 +412,7 @@ kmem_cache_free(posix_timers_cache, tmr); tmr =3D 0; } + INIT_LIST_HEAD(&tmr->abs_timer_entry); return tmr; } =20 @@ -787,6 +798,7 @@ { struct k_clock *clock =3D &posix_clocks[timr->it_clock]; u64 expire_64; + unsigned long seq; =20 if (old_setting) do_timer_gettime(timr, old_setting); @@ -813,6 +825,11 @@ #else del_timer(&timr->it_timer); #endif + if (CLOCK_REALTIME =3D=3D timr->it_clock) { + spin_lock(&clock->abs_timer_lock); + list_del_init(&timr->abs_timer_entry); + spin_unlock(&clock->abs_timer_lock); + } timr->it_requeue_pending =3D (timr->it_requeue_pending + 2) &=20 ~REQUEUE_PENDING; timr->it_overrun_last =3D 0; @@ -834,7 +851,6 @@ tstojiffie(&new_setting->it_interval, clock->res, &expire_64); timr->it_incr =3D (unsigned long)expire_64; =20 - /* * For some reason the timer does not fire immediately if expires is * equal to jiffies, so the timer notify function is called directly. @@ -843,8 +859,21 @@ if (((timr->it_sigev_notify & ~SIGEV_THREAD_ID) !=3D SIGEV_NONE)) { if (timr->it_timer.expires =3D=3D jiffies) timer_notify_task(timr); - else + else { add_timer(&timr->it_timer); + if (flags & TIMER_ABSTIME && + timr->it_clock =3D=3D CLOCK_REALTIME) { + spin_lock(&clock->abs_timer_lock); + do { + seq =3D read_seqbegin(&xtime_lock); + timr->wall_to_monotonic_prev = =3D + wall_to_monotonic; + } while (read_seqretry(&xtime_lock, seq)); + list_add_tail(&(timr->abs_timer_entry), + &(clock->abs_timer_list)); + spin_unlock(&clock->abs_timer_lock); + } + } } return 0; } @@ -875,10 +904,10 @@ if (!timr) return -EINVAL; =20 - if (!posix_clocks[timr->it_clock].timer_set) + if (!posix_clocks[timr->it_clock].timer_set)=20 error =3D do_timer_settime(timr, flags, &new_spec, rtn); else - error =3D posix_clocks[timr->it_clock].timer_set(timr, + error =3D posix_clocks[timr->it_clock].timer_set(timr, flags, =20 &new_spec, rtn); unlock_timer(timr, flag); @@ -911,6 +940,11 @@ #else del_timer(&timer->it_timer); #endif + if (CLOCK_REALTIME =3D=3D timer->it_clock) { + spin_lock(&posix_clocks[CLOCK_REALTIME].abs_timer_lock); + list_del_init(&timer->abs_timer_entry); + spin_unlock(&posix_clocks[CLOCK_REALTIME].abs_timer_lock); + } =20 return 0; } =20 @@ -1086,10 +1120,10 @@ { struct timespec new_tp; =20 - if ((unsigned) which_clock >=3D MAX_CLOCKS || + if ((unsigned) which_clock >=3D MAX_CLOCKS || !posix_clocks[which_clock].res) return -EINVAL; - if (copy_from_user(&new_tp, tp, sizeof (*tp))) + if (copy_from_user(&new_tp, tp, sizeof (*tp))) return -EFAULT; if (posix_clocks[which_clock].clock_set) return posix_clocks[which_clock].clock_set(&new_tp); @@ -1159,7 +1193,55 @@ =20 void clock_was_set(void) { + struct k_clock *clock =3D &posix_clocks[CLOCK_REALTIME]; + struct k_itimer *timr, *tmp; + struct timespec delta; + u64 exp =3D 0; + unsigned long seq; + =20 wake_up_all(&nanosleep_abs_wqueue); + + /* + * Check if there exist TIMER_ABSTIME timers to correct. + */ + if (list_empty(&clock->abs_timer_list)) + return; + + spin_lock(&clock->abs_timer_lock); + list_for_each_entry_safe(timr, tmp, + &clock->abs_timer_list, + abs_timer_entry) { + do { + seq =3D read_seqbegin(&xtime_lock); + delta.tv_sec =3D + wall_to_monotonic.tv_sec + - timr->wall_to_monotonic_prev.tv_sec; + delta.tv_nsec =3D=20 + wall_to_monotonic.tv_nsec + - timr->wall_to_monotonic_prev.tv_nsec; + } while (read_seqretry(&xtime_lock, seq)); + =20 + while (delta.tv_nsec >=3D NSEC_PER_SEC) { + delta.tv_sec ++; + delta.tv_nsec -=3D NSEC_PER_SEC; + } + while (delta.tv_nsec < 0) { + delta.tv_sec --; + delta.tv_nsec +=3D NSEC_PER_SEC; + } + do { + seq =3D read_seqbegin(&xtime_lock); + timr->wall_to_monotonic_prev =3D wall_to_monotonic; + } while (read_seqretry(&xtime_lock, seq)); + =20 + tstojiffie(&delta, clock->res, &exp); + if (del_timer(&timr->it_timer)) { /* the timer has not run */ + timr->it_timer.expires +=3D exp;=20 + add_timer(&timr->it_timer); + } else=20 + list_del_init(&timr->abs_timer_entry); + } + spin_unlock(&clock->abs_timer_lock); } =20 long clock_nanosleep_restart(struct restart_block *restart_block); Boris Hu (Hu Jiangtao) ***************************************** There are my thoughts, not my employer's. ***************************************** > > Here is one update version. wall_to_monotonic copy has been moved to > > k_itimer. Thanks. >=20 > As far as it goes... the update of the k_timer wall_to_monotonic should > be the > same as that which is used to do the correction. I.e. it should be done > within > the same lock region. >=20 > I will be out of town till Tuesday or Wed. next week.... >=20 > George > > ------_=_NextPart_001_01C44C53.6BBC45A6 Content-Type: application/octet-stream; name="posix-abs_timer-bugfix-0.3.diff" Content-Transfer-Encoding: base64 Content-Description: posix-abs_timer-bugfix-0.3.diff Content-Disposition: attachment; filename="posix-abs_timer-bugfix-0.3.diff" ZGlmZiAtdXJOIC1YIGRvbnRkaWZmIGxpbnV4LTIuNi42L2luY2x1ZGUvbGludXgvcG9zaXgtdGlt ZXJzLmggbGludXgtMi42LjYuZGV2L2luY2x1ZGUvbGlud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+UkVRVUVVRV9QRU5ESU5HOwogCXRpbXItPml0X292ZXJydW5fbGFz dCA9IDA7CkBAIC04MzQsNyArODUxLDYgQEAKIAl0c3RvamlmZmllKCZuZXdfc2V0dGluZy0+aXRf aW50ZXJ2YWwsIGNsb2NrLT5yZXMsICZleHBpcmVfNjQpOwogCXRpbXItPml0X2luY3IgPSAodW5z aWduZWQgbG9uZylleHBpcmVfNjQ7CiAKLQogCS8qCiAJICogRm9yIHNvbWUgcmVhc29uIHRoZSB0 aW1lciBkb2VzIG5vdCBmaXJlIGltbWVkaWF0ZWx5IGlmIGV4cGlyZXMgaXMKIAkgKiBlcXVhbCB0 byBqaWZmaWVzLCBzbyB0aGUgdGltZXIgbm90aWZ5IGZ1bmN0aW9uIGlzIGNhbGxlZCBkaXJlY3Rs eS4KQEAgLTg0Myw4ICs4NTksMjEgQEAKIAlpZiAoKCh0aW1yLT5pdF9zaWdldl9ub3RpZnkgJiB+ U0lHRVZfVEhSRUFEX0lEKSAhPSBTSUdFVl9OT05FKSkgewogCQlpZiAodGltci0+aXRfdGltZXIu ZXhwaXJlcyA9PSBqaWZmaWVzKQogCQkJdGltZXJfbm90aWZ5X3Rhc2sodGltcik7Ci0JCWVsc2UK KwkJZWxzZSB7CiAJCQlhZGRfdGltZXIoJnRpbXItPml0X3RpbWVyKTsKKyAgICAgICAgICAgICAg ICAgICAgICAgIGlmIChmbGFncyAmIFRJTUVSX0FCU1RJTUUgJiYKKyAgICAgICAgICAgICAgICAg ICAgICAgICAgICB0aW1yLT5pdF9jbG9jayA9PSBDTE9DS19SRUFMVElNRSkgeworICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBzcGluX2xvY2soJmNsb2NrLT5hYnNfdGltZXJfbG9jayk7 CisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRvIHsKKyAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgICBzZXEgPSByZWFkX3NlcWJlZ2luKCZ4dGltZV9sb2NrKTsK KyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aW1yLT53YWxsX3RvX21v bm90b25pY19wcmV2ID0KKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICAgICAgIHdhbGxfdG9fbW9ub3RvbmljOworICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg ICB9IHdoaWxlIChyZWFkX3NlcXJldHJ5KCZ4dGltZV9sb2NrLCBzZXEpKTsKKyAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAgbGlzdF9hZGRfdGFpbCgmKHRpbXItPmFic190aW1lcl9lbnRy eSksCisgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJihjbG9j ay0+YWJzX3RpbWVyX2xpc3QpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3Bp bl91bmxvY2soJmNsb2NrLT5hYnNfdGltZXJfbG9jayk7CisgICAgICAgICAgICAgICAgICAgICAg ICB9CisgICAgICAgICAgICAgICAgfQogCX0KIAlyZXR1cm4gMDsKIH0KQEAgLTg3NSwxMCArOTA0 LDEwIEBACiAJaWYgKCF0aW1yKQogCQlyZXR1cm4gLUVJTlZBTDsKIAotCWlmICghcG9zaXhfY2xv Y2tzW3RpbXItPml0X2Nsb2NrXS50aW1lcl9zZXQpCisJaWYgKCFwb3NpeF9jbG9ja3NbdGltci0+ aXRfY2xvY2tdLnRpbWVyX3NldCkgCiAJCWVycm9yID0gZG9fdGltZXJfc2V0dGltZSh0aW1yLCBm bGFncywgJm5ld19zcGVjLCBydG4pOwogCWVsc2UKLQkJZXJyb3IgPSBwb3NpeF9jbG9ja3NbdGlt ci0+aXRfY2xvY2tdLnRpbWVyX3NldCh0aW1yLAorICAgICAgICAgICAgICAgIGVycm9yID0gcG9z aXhfY2xvY2tzW3RpbXItPml0X2Nsb2NrXS50aW1lcl9zZXQodGltciwKIAkJCQkJCQkgICAgICAg ZmxhZ3MsCiAJCQkJCQkJIC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tdLmNsb2NrX3NldCgmbmV3 X3RwKTsKQEAgLTExNTksNyArMTE5Myw1NSBAQAogCiB2b2lkIGNsb2NrX3dhc19zZXQodm9pZCkK IHsKKyAgICAgICAgc3RydWN0IGtfY2xvY2sgKmNsb2NrID0gJnBvc2l4X2Nsb2Nrc1tDTE9DS19S RUFMVElNRV07CisgICAgICAgIHN0cnVjdCBrX2l0aW1lciAqdGltciwgKnRtcDsKKyAgICAgICAg c3RydWN0IHRpbWVzcGVjIGRlbHRhOworICAgICAgICB1NjQgZXhwID0gMDsKKyAgICAgICAgdW5z aWduZWQgbG9uZyBzZXE7CisgICAgICAgIAogCXdha2VfdXBfYWxsKCZuYW5vc2xlZXBfYWJzX3dx dWV1ZSk7CisKKyAgICAgICAgLyoKKyAgICAgICAgICogQ2hlY2sgaWYgdGhlcmUgZXhpc3QgVElN RVJfQUJTVElNRSB0aW1lcnMgdG8gY29ycmVjdC4KKyAgICAgICAgICovCisgICAgICAgIGlmIChs aXN0X2VtcHR5KCZjbG9jay0+YWJzX3RpbWVyX2xpc3QpKQorICAgICAgICAgICAgICAgIHJldHVy bjsKKworICAgICAgICBzcGluX2xvY2soJmNsb2NrLT5hYnNfdGltZXJfbG9jayk7CisgICAgICAg IGxpc3RfZm9yX2VhY2hfZW50cnlfc2FmZSh0aW1yLCB0bXAsCisgICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAmY2xvY2stPmFic190aW1lcl9saXN0LAorICAgICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgYWJzX3RpbWVyX2VudHJ5KSB7CisgICAgICAgICAgICAgICAgZG8gewor ICAgICAgICAgICAgICAgICAgICAgICAgc2VxID0gcmVhZF9zZXFiZWdpbigmeHRpbWVfbG9jayk7 CisgICAgICAgICAgICAgICAgICAgICAgICBkZWx0YS50dl9zZWMgPQorICAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICB3YWxsX3RvX21vbm90b25pYy50dl9zZWMKKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgLSB0aW1yLT53YWxsX3RvX21vbm90b25pY19wcmV2LnR2X3NlYzsK KyAgICAgICAgICAgICAgICAgICAgICAgIGRlbHRhLnR2X25zZWMgPSAKKyAgICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgd2FsbF90b19tb25vdG9uaWMudHZfbnNlYworICAgICAgICAgICAg ICAgICAgICAgICAgICAgICAgICAtIHRpbXItPndhbGxfdG9fbW9ub3RvbmljX3ByZXYudHZfbnNl YzsKKyAgICAgICAgICAgICAgICB9IHdoaWxlIChyZWFkX3NlcXJldHJ5KCZ4dGltZV9sb2NrLCBz ZXEpKTsKKyAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICB3aGlsZSAoZGVsdGEudHZf bnNlYyA+PSBOU0VDX1BFUl9TRUMpIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRlbHRhLnR2 X3NlYyArKzsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRlbHRhLnR2X25zZWMgLT0gTlNFQ19Q RVJfU0VDOworICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICB3aGlsZSAoZGVsdGEu dHZfbnNlYyA8IDApIHsKKyAgICAgICAgICAgICAgICAgICAgICAgIGRlbHRhLnR2X3NlYyAtLTsK KyAgICAgICAgICAgICAgICAgICAgICAgIGRlbHRhLnR2X25zZWMgKz0gTlNFQ19QRVJfU0VDOwor ICAgICAgICAgICAgICAgIH0KKyAgICAgICAgICAgICAgICBkbyB7CisgICAgICAgICAgICAgICAg ICAgICAgICBzZXEgPSByZWFkX3NlcWJlZ2luKCZ4dGltZV9sb2NrKTsKKyAgICAgICAgICAgICAg ICAgICAgICAgIHRpbXItPndhbGxfdG9fbW9ub3RvbmljX3ByZXYgPSB3YWxsX3RvX21vbm90b25p YzsKKyAgICAgICAgICAgICAgICB9IHdoaWxlIChyZWFkX3NlcXJldHJ5KCZ4dGltZV9sb2NrLCBz ZXEpKTsKKyAgICAgICAgICAgICAgICAgICAgICAgICAKKyAgICAgICAgICAgICAgICB0c3Rvamlm ZmllKCZkZWx0YSwgY2xvY2stPnJlcywgJmV4cCk7CisgICAgICAgICAgICAgICAgaWYgKGRlbF90 aW1lcigmdGltci0+aXRfdGltZXIpKSB7IC8qIHRoZSB0aW1lciBoYXMgbm90IHJ1biAqLworICAg ICAgICAgICAgICAgICAgICAgICAgdGltci0+aXRfdGltZXIuZXhwaXJlcyArPSBleHA7IAorICAg ICAgICAgICAgICAgICAgICAgICAgYWRkX3RpbWVyKCZ0aW1yLT5pdF90aW1lcik7CisgICAgICAg ICAgICAgICAgfSBlbHNlIAorICAgICAgICAgICAgICAgICAgICAgICAgbGlzdF9kZWxfaW5pdCgm dGltci0+YWJzX3RpbWVyX2VudHJ5KTsKKyAgICAgICAgfQorICAgICAgICBzcGluX3VubG9jaygm Y2xvY2stPmFic190aW1lcl9sb2NrKTsKIH0KIAogbG9uZyBjbG9ja19uYW5vc2xlZXBfcmVzdGFy dChzdHJ1Y3QgcmVzdGFydF9ibG9jayAqcmVzdGFydF9ibG9jayk7Cg== ------_=_NextPart_001_01C44C53.6BBC45A6-- - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/