Skip to content

Linux port hdd timers2 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 12, 2015

Conversation

frankeh
Copy link
Contributor

@frankeh frankeh commented Dec 9, 2015

Additional changes to handle Timers using kevent properly.

dgrove-oss and others added 2 commits December 9, 2015 21:11
- reduce kevent64 to kevent usage: implies time management in
  dispatch_timers_program2 moves from absolute to relative and to msecs
  as that's what kevent can handle right now
- properly defined NOTE_xxxxx macros
- configure.ac change to define HAVE_KEVENT64

Squashed commit of the following:

commit dfe7b8b
Merge: e25ec26 6293e78
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Wed Dec 9 15:38:11 2015 -0500

    Merge branch 'linux-port-hdd' of github.ibm.com:ibmswift/swift-corelibs-libdispatch into linux-port-hdd

commit e25ec26
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Wed Dec 9 15:37:38 2015 -0500

    reduce the impact of kevent64

commit 6293e78
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 9 17:59:59 2015 +0000

    kqueue check now also looks for kevent64 and sets config.h accordingly

commit 53a8aa6
Merge: b02031c cff30c4
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 9 15:16:21 2015 +0000

    Merge branch 'linux-port-hdd' of github.ibm.com:ibmswift/swift-corelibs-libdispatch into linux-port-hdd

commit cff30c4
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Wed Dec 9 06:59:09 2015 -0500

    check only one event is returned in kevent() call to allow type coercion

commit 884bd36
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Tue Dec 8 22:58:41 2015 -0500

    kevent64 shim turns time negative in absolute to relative conversion. Checked for it

commit e48115b
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Tue Dec 8 21:49:29 2015 -0500

    fix periodic timers through kevent rewrite and fix definition for linux

commit b02031c
Merge: 7f64b1c 14f0250
Author: David Grove <groved@us.ibm.com>
Date:   Sun Dec 6 19:21:44 2015 +0000

    Merge branch 'master' of github.com:apple/swift-corelibs-libdispatch into linux-port-hdd

commit 7f64b1c
Author: David Grove <groved@us.ibm.com>
Date:   Sat Dec 5 16:55:30 2015 +0000

    fix mistake made in merge

commit d2f10b3
Merge: fae40d1 394d9a1
Author: David Grove <groved@us.ibm.com>
Date:   Sat Dec 5 16:38:51 2015 +0000

    Merge branch 'master' into linux-port-hdd

commit fae40d1
Merge: a93074c acd56f6
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 20:49:43 2015 +0000

    Merge branch 'master' into linux-port-hdd

commit a93074c
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 20:44:13 2015 +0000

    cleanups

commit 10b9e94
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 20:36:14 2015 +0000

    don't add os/base.h

commit bc04960
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 20:27:25 2015 +0000

    WIP cleanup

commit b741481
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 20:02:14 2015 +0000

    addressing commenrts from pull request

commit 6de4767
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 18:08:40 2015 +0000

    use __APPLE__ instead of HAVE_MACH

commit f87caf9
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 18:05:06 2015 +0000

    Copy BSD sys/queue.h to shims/sys_queue.h and remove HACK around SAFE macros

commit e3652d6
Author: David Grove <groved@us.ibm.com>
Date:   Fri Dec 4 16:26:21 2015 +0000

    Expand comments and reorganize;  remove mistaken redefine of DISPATCH_EXPORT macros

commit dd656be
Author: David Grove <groved@us.ibm.com>
Date:   Thu Dec 3 22:20:46 2015 +0000

    revert back to matching kevent64_s definition from OS X man page for kevent

commit 02616b0
Merge: 2453edc 650f82a
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Thu Dec 3 17:04:24 2015 -0500

    merged conflicts

commit 2453edc
Author: Hubertus Franke <frankeh@us.ibm.com>
Date:   Thu Dec 3 17:00:27 2015 -0500

    fixed kevent, running till dispatch with bugs still in queue counts

commit 650f82a
Author: David Grove <groved@us.ibm.com>
Date:   Thu Dec 3 01:16:32 2015 +0000

    license headers on added files

commit 16d8a2c
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 2 22:26:40 2015 +0000

    fix stubbed functions to have the right prototype and abort in their bodies when called

commit a6ede63
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 2 17:07:16 2015 +0000

    update stubs and typedefs after merge of pull-request 2 from master

commit f38ebb9
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 2 17:05:57 2015 +0000

    remove workaround; type now defined in proper header file

commit e0f0522
Merge: 8d8bb46 39ac720
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 2 16:46:42 2015 +0000

    Merge branch 'master' into linux-port-hdd

commit 8d8bb46
Author: David Grove <groved@us.ibm.com>
Date:   Wed Dec 2 01:40:23 2015 +0000

    stub out missing functions and statics with dummy definitions

commit 9f4f103
Author: David Grove <groved@us.ibm.com>
Date:   Tue Dec 1 16:02:11 2015 +0000

    Update list of header files to be installed for dispatch and os.
    Move stubs.h to stubs_internal.h and include it from internal.h
    (so we don't need to install stubs to get a complete set of header files).

commit 9a39fef
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 21:52:38 2015 +0000

    clang on linux just ignores -compatibility_version instead of failing
    with an unknown error message (despite the fact that ld won't actually
    understand the argument, so linking will actually fail in the end).

    This is a hack to generate workable makefiles; it may not be the right fix...

commit efa2a28
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 21:51:59 2015 +0000

    ignore .la files

commit 35984ca
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 21:34:28 2015 +0000

    WIP on getting code to compile

commit 2ab2c26
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 21:04:26 2015 +0000

    slightly suspect changes to get semaphore.c to compile.
    The existing code was clearly wrong, but this might not be
    the right way to fix it either...

commit d7fe4b0
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 20:48:04 2015 +0000

    tweaks to get it to compile

commit da3b73d
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 19:06:27 2015 +0000

    WIP on stubbing out missing pieces to get code to compile

commit 4f9b58c
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 18:06:33 2015 +0000

    synthesize declarations of missing observer types

commit fdeae8a
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 18:05:58 2015 +0000

    guard include of mach.h with HAVE_MACH

commit f013a99
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 18:05:02 2015 +0000

    ignore autotools and libtool generated files

commit f22bc4b
Author: David Grove <groved@us.ibm.com>
Date:   Mon Nov 30 18:02:50 2015 +0000

    header files to stub out types/functions for linux port
@@ -1858,13 +1858,27 @@ _dispatch_timers_get_delay(uint64_t nows[], struct dispatch_timer_s timer[],
return ridx;
}


#if HAVE_KEVENT64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this block is wrong, and in any case should live in shims/time.h

I think what you mean here is "do we have support for NOTE_NSECONDS"
and not "do we have KEVENT64", you would break FreeBSD doing this.

Please do not mingle OS support with code, use shims/ and clean wrappers.

It'd be best to push NOTE_NSECOND support in libkqueue in the first place, which is probably easiest, so that you can use the thing directly anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. The intention initially was to get something running.
I agree that better place to get this moved is libkqueue which internally uses nsec time management anyway. We can squash this patch set, clean it up w/o kevent64(@libkqueue)
for now according to your suggestions (shims/time.h) and then do a full update on the
libkqueue to bring kevent64 semantics as known in BSD to that implementation.
Frankly I prefer that, though not sure yet how to do with the EVFILTER_TIMER.leeway semantics. Where will we host the libkqueue, seems like Haileys has not been active for a while.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that your patch most likely breaks Mac OS too, so we can't take that even for the sake of the linux port making progress.

the leeway argument is easy: it's always correct to ignore it. it's about "can I delay firing that timer a bit so that I can coalesce several timers firing approximatively at the same time and save power by waking up the CPU once" If you don't do it, the code is still correct.

dgrove-oss and others added 2 commits December 10, 2015 11:55
Need to run this check independent of the check for sys/event64
so that HAVE_KEVENT64 will be checked and defined on all platforms.
@frankeh
Copy link
Contributor Author

frankeh commented Dec 10, 2015

Took your generic advice. Cleaned up the sloppy code. However moving things to shims/*.h
seems to create typedef dependencies. Created a linux conditionals outside
the _dispatch_timers_program2 .. this is reasonable minimal.

_dispatch_source_timer_now(nows, DISPATCH_TIMER_KIND_WALL); // called to return nows[]

delay /= 1000000L;
if ((int64_t)(delay) <= 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tab/space issue.
we use 4-width tabs.

Our coding rules are (in vim speak):

set cinoptions=
set cinoptions+=Ls
set cinoptions+=:0,=1s
set cinoptions+=t0
set cinoptions+=+2s,(2s,u2s,W2s
set cinoptions+=j1,J1,m1
au FileType d,c,cpp,objc setlocal tw=80 ts=4 sw=4 noet

please fix the mixed indent here

@MadCoder
Copy link
Contributor

I like this approach much better, the remarks I made are now purely cosmetical, please fix them, I tend to leave linux_stubs* alone until it converges, but please respect coding rules outside of this

we'll update a document to explain them more clearly for future contributions shortly.

thanks!

MadCoder added a commit that referenced this pull request Dec 12, 2015
@MadCoder MadCoder merged commit 6dbebd6 into swiftlang:master Dec 12, 2015
@dgrove-oss dgrove-oss deleted the linux-port-hdd-timers2 branch December 14, 2015 15:45
das pushed a commit that referenced this pull request Jun 14, 2016
Linux port hdd timers2

Signed-off-by: Daniel A. Steffen <dsteffen@apple.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants