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
Unknown Object (File)
Wed, Dec 11, 3:25 AM
Unknown Object (File)
Fri, Dec 6, 10:00 PM
Unknown Object (File)
Tue, Dec 3, 10:17 PM
Unknown Object (File)
Nov 18 2024, 11:16 PM
Unknown Object (File)
Nov 14 2024, 9:03 PM
Unknown Object (File)
Oct 4 2024, 2:02 AM
Unknown Object (File)
Oct 1 2024, 8:36 PM
Unknown Object (File)
Sep 29 2024, 11:22 PM
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

Lint
Lint Skipped
Unit
Tests Skipped

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

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

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

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

Just want to make it consistent w/ hashinit :)

130

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.