Skip to content

Conversation

@devnexen
Copy link
Collaborator

Cannot enforce alignment so we just check its correctness.

Cannot enforce alignment so we just check its correctness.
@msftclas
Copy link

msftclas commented Jul 30, 2019

CLA assistant check
All CLA requirements met.

Copy link
Collaborator

@davidchisnall davidchisnall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a lot of code copied and pasted from the FreeBSD PAL here. Please can you pull that out into a common generic BSD PAL? I think that the OpenBSD one will likely be the generic one and FreeBSD is that plus the addition of support for aligned allocation support.

* Bitmap of PalFeatures flags indicating the optional features that this
* PAL supports.
*/
static constexpr uint64_t pal_features = AlignedAllocation | LazyCommit;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can't guarantee alignment, then don't advertise that you support aligned allocation - the code using the PAL will fix this for you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was

There's a lot of code copied and pasted from the FreeBSD PAL here. Please can you pull that out into a common generic BSD PAL? I think that the OpenBSD one will likely be the generic one and FreeBSD is that plus the addition of support for aligned allocation support.

It was to avoid too many ifdef

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can't guarantee alignment, then don't advertise that you support aligned allocation - the code using the PAL will fix this for you.

Yes useless flag indeed.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant pull out the common functions into a shared superclass, not add a mess of ifdefs...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry my bad :-)

Copy link
Member

@mjp41 mjp41 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me. Thanks for your contribution. @davidchisnall can you double check

class PALOBSD : public PALBSD
{
public:
static constexpr uint64_t pal_features = LazyCommit;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you include this line in the PALBSD, then we can remove this file, and just use PALBSD for OpenBSD and extend it for FreeBSD.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I considered this but was not sure if one day OpenBSD would need a particular treatment (ie having special mmap flags nothing else has).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the right thing to do here (from the perspective of making the code readable) is for the BSD PAL to set LazyCommit and for the OpenBSD PAL to declare pal_features but set it to PALBSD::pal_features, so if anyone needs to extend this class with non-generic behaviour later then they have a reminder to do so. I'll make that change when I do some cleanup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem at all with that, result is the same just make the "inheritance" reminder clearer indeed.

@davidchisnall davidchisnall merged commit 5c22521 into microsoft:master Aug 1, 2019
@davidchisnall
Copy link
Collaborator

Now that the BSD back ends are merged, the Linux one looks quite untidy. I think I will try to refactor some of it into a POSIX PAL today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants