Page MenuHomeFreeBSD

kern: Add phashinit_flags(), which allows malloc(M_NOWAIT)
ClosedPublic

Authored by sepherosa_gmail.com on Apr 28 2016, 8:41 AM.
Tags
None
Referenced Files
F81594657: D6138.id15840.diff
Thu, Apr 18, 4:35 PM
F81594439: D6138.id15724.diff
Thu, Apr 18, 4:31 PM
F81585368: D6138.id15724.diff
Thu, Apr 18, 12:51 PM
Unknown Object (File)
Wed, Apr 17, 9:04 PM
Unknown Object (File)
Wed, Apr 17, 8:59 PM
Unknown Object (File)
Wed, Apr 17, 5:46 PM
Unknown Object (File)
Mar 17 2024, 9:15 AM
Unknown Object (File)
Mar 17 2024, 8:53 AM
Subscribers
None

Details

Summary

It will be used for the upcoming LRO hash table initialization. And probably will be useful in other cases, when M_WAITOK can't be used.

Diff Detail

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

Event Timeline

sepherosa_gmail.com retitled this revision from to kern: Add phashinit_flags(), which allows malloc(M_NOWAIT).
sepherosa_gmail.com updated this object.
sepherosa_gmail.com edited the test plan for this revision. (Show Details)
sys/sys/systm.h
193 ↗(On Diff #15688)

I think you can drop the comment for the variable in the prototype as that isn't typical style in FreeBSD. There is a manpage for hashinit/phashinit that should be updated for this new function as well. That is where the meaning of the flags argument should be documented instead.

sys/kern/subr_hash.c
111 ↗(On Diff #15688)

To my taste, the new name is too long. We often call such enhanced functions e.g. phashinit1(). I understand that you just copied what was done to hashinit.

130 ↗(On Diff #15688)

You wrote the assert expression in very compact way. Why spend 4 lines to translate flags ?

m_flags = (flags & HASH_NOWAIT) != 0 ? M_NOWAIT : M_WAITOK;
sys/kern/subr_hash.c
111 ↗(On Diff #15688)

Just want to make it consistent w/ hashinit :)

130 ↗(On Diff #15688)

KASSERT was copied too :P

And, well, when copying the malloc, I just noticed that part duplicates too much code (two malloc(...) lines), so we saw what I posted here.

Yeah, compat form is fine w/ me.

kib edited edge metadata.
This revision is now accepted and ready to land.Apr 29 2016, 7:40 AM
jhb edited edge metadata.

Maybe as a followup fix hashinit_flags() to not duplicate the malloc and instead use the logic you used in phashinit_flags(). That's optional though (and I wouldn't include it as part of this change).

In D6138#130946, @jhb wrote:

Maybe as a followup fix hashinit_flags() to not duplicate the malloc and instead use the logic you used in phashinit_flags(). That's optional though (and I wouldn't include it as part of this change).

Yeah, sure.

This revision was automatically updated to reflect the committed changes.