-
Notifications
You must be signed in to change notification settings - Fork 470
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
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
aca0d3c
Cleanup of kevent usage
dgrove-oss 3809a10
moved the kevent time adjustment in _dispatch_timers_program2 to prop…
frankeh 907c677
fix placement of CHECK_LIBS test for kevent64
dgrove-oss d76ef08
reduce impact of linux on the previous kevent changes
frankeh 8b0e8f8
address Pierre Habouzit's formatting and naming convention requests
frankeh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1858,13 +1858,27 @@ _dispatch_timers_get_delay(uint64_t nows[], struct dispatch_timer_s timer[], | |
return ridx; | ||
} | ||
|
||
|
||
#if HAVE_KEVENT64 | ||
# define kevent_set_ext1(ke,val) (ke)->ext[1] = (val) | ||
# define adjust_delay(delay,at) (delay) += (at) | ||
#else | ||
# define kevent_set_ext1(ke,val) do { } while (0) | ||
# define adjust_delay(delay,at) \ | ||
do { \ | ||
delay /= 1000000L; \ | ||
if ((int64_t)(delay) <= 0) delay = 1; /* for some reason time turns negative */ \ | ||
} while (0) | ||
|
||
#endif | ||
|
||
static bool | ||
_dispatch_timers_program2(uint64_t nows[], _dispatch_kevent_qos_s *ke, | ||
unsigned int qos) | ||
{ | ||
unsigned int tidx; | ||
bool poll; | ||
uint64_t delay, leeway; | ||
uint64_t delay, leeway, nowtime; | ||
|
||
tidx = _dispatch_timers_get_delay(nows, _dispatch_timer, &delay, &leeway, | ||
(int)qos); | ||
|
@@ -1881,13 +1895,15 @@ _dispatch_timers_program2(uint64_t nows[], _dispatch_kevent_qos_s *ke, | |
_dispatch_trace_next_timer_set( | ||
TAILQ_FIRST(&_dispatch_kevent_timer[tidx].dk_sources), qos); | ||
_dispatch_trace_next_timer_program(delay, qos); | ||
delay += _dispatch_source_timer_now(nows, DISPATCH_TIMER_KIND_WALL); | ||
nowtime =_dispatch_source_timer_now(nows, DISPATCH_TIMER_KIND_WALL); | ||
adjust_delay(delay,nowtime); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should be removed, and libkqueue updated to do conversions from ns to ms internally instead. |
||
|
||
if (slowpath(_dispatch_timers_force_max_leeway)) { | ||
ke->data = (int64_t)(delay + leeway); | ||
ke->ext[1] = 0; | ||
kevent_set_ext1(ke,0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
} else { | ||
ke->data = (int64_t)delay; | ||
ke->ext[1] = leeway; | ||
kevent_set_ext1(ke,leeway); | ||
} | ||
ke->flags |= EV_ADD|EV_ENABLE; | ||
ke->flags &= ~EV_DELETE; | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.