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)
Feb 27 2024, 8:59 PM
Unknown Object (File)
Dec 20 2023, 6:00 AM
Unknown Object (File)
Dec 13 2023, 2:56 PM
Unknown Object (File)
Aug 15 2023, 5:34 AM
Unknown Object (File)
Jul 27 2023, 5:16 AM
Unknown Object (File)
May 16 2023, 12:08 AM
Unknown Object (File)
Apr 20 2023, 6:36 PM
Unknown Object (File)
Jan 6 2023, 4:25 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.