Page MenuHomeFreeBSD

inline swp_pager_isondev() function and use it 2 other places
ClosedPublic

Authored by ota_j.email.ne.jp on Aug 15 2018, 3:11 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 30, 7:38 PM
Unknown Object (File)
Oct 23 2024, 3:17 AM
Unknown Object (File)
Oct 23 2024, 3:17 AM
Unknown Object (File)
Oct 23 2024, 3:17 AM
Unknown Object (File)
Oct 23 2024, 3:17 AM
Unknown Object (File)
Oct 23 2024, 2:57 AM
Unknown Object (File)
Oct 1 2024, 8:53 PM
Unknown Object (File)
Sep 24 2024, 2:09 AM
Subscribers

Details

Summary

Simplify code and take advantage of inline function.

Ref: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=223640

Test Plan

Use memory to trigger and cause swapins and swapouts.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/vm/swap_pager.c
766 ↗(On Diff #46686)

Please eliminate the space between "swp_pager_isondev" and "(".

800 ↗(On Diff #46686)

Ditto.

sys/vm/swap_pager.c
752 ↗(On Diff #46686)

Does inline change anything in the generated code ?

ota_j.email.ne.jp added inline comments.
sys/vm/swap_pager.c
1749 ↗(On Diff #46758)

This had been the only caller.

752 ↗(On Diff #46686)

C99 introduced inline function.
Compiler can choose to embed code into each callers instead of making a function call at each location.

If a compiler optimizes, this change won't have a function call overhead and will be the same. We have one existing caller that can benefit inline.

I didn't check resulted code in FreeBSD, though; I saw lots of other inline functions in FreeBSD code and expected we had been taking advantages.

sys/vm/swap_pager.c
752 ↗(On Diff #46686)

I believe that Kostik's point is that clang will automatically inline this function without the need for explicitly defining the function as inline.

This revision is now accepted and ready to land.Aug 16 2018, 6:14 AM
sys/vm/swap_pager.c
752 ↗(On Diff #46686)

The generated code is the same with or without the explicit inline.

Prefer to remove the inline keyword.

In D16712#385624, @kib wrote:

Prefer to remove the inline keyword.

Okay, I'm going to commit this change in a few hours without the inline keyword.

In D16712#385630, @alc wrote:
In D16712#385624, @kib wrote:

Prefer to remove the inline keyword.

Okay, I'm going to commit this change in a few hours without the inline keyword.

I'm also going to change the return type for swp_pager_isondev() to bool.

This revision was automatically updated to reflect the committed changes.