Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

rpma: mmap() memory for rpma_mr_reg() in rpma_flush_apm_new() #866

Conversation

ldorau
Copy link
Member

@ldorau ldorau commented Feb 9, 2021

The memory region passed to rpma_mr_reg() (ibv_mr_reg())
cannot be allocated from the heap (using malloc()
or posix_memalign()), but should be mapped using mmap().

Rationale:

If ibv_fork_init() was called, the memory region
passed to ibv_mr_reg() is marked by this function
with the DC (“do not copy on fork”) flag
and after having called fork(), the child process
does not receive this range of virtual addresses.
If this memory region was allocated from the heap,
the child process receives a corrupted heap
with a “hole” of inaccessible addresses inside.
A memory allocator knows nothing about this “hole”
and if it tries to access (read or write)
that range of virtual addresses, it causes a segfault.

Ref: #751


This change is Reviewable

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from d1e22d1 to 07ff945 Compare February 9, 2021 15:04
@ldorau
Copy link
Member Author

ldorau commented Feb 9, 2021

Ref: #751

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from 07ff945 to e04b4e1 Compare February 9, 2021 15:08
Copy link
Member

@pbalcer pbalcer left a comment

Choose a reason for hiding this comment

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

👍 but I'd wrap the mmap in some util function if you plan to allocate memory like that somewhere else.

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

@pbalcer We do not plan - as for now - in the library itself, only in a new example that will be added soon (an example dedicated for the fork() function).

Reviewable status: 0 of 15 files reviewed, all discussions resolved

Copy link
Contributor

@grom72 grom72 left a comment

Choose a reason for hiding this comment

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

Shall we also fix malloc_aligned() in example/common/cpommon-conn.c?
or in the context of @pbalcer 's suggestion shall we have common utils function in librpma API that is used in examples as well as in the library (flush_apm_new)?

Reviewed 14 of 15 files at r1, 1 of 1 files at r2.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @ldorau)


src/flush.h, line 37 at r2 (raw file):

RPMA_E_INVAL

Is there any UT for RPMA_E_INVAL return value?


src/flush.c, line 78 at r2 (raw file):

munmap(raw, mmap_size);

(void) munmap(raw, mmap_size);


src/flush.c, line 85 at r2 (raw file):

munmap(raw, mmap_size);

.


tests/unit/common/mocks-stdlib.h, line 11 at r2 (raw file):

posix_memalign_args

do we need this?


tests/unit/common/mocks-stdlib.c, line 36 at r2 (raw file):

__wrap_posix_memalign

Is it still in use in any UT?


tests/unit/flush/flush-new.c, line 57 at r2 (raw file):

posix_memalign_ENOMEM

mmap_ENOMEM

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @grom72 and @ldorau)


src/flush.c, line 78 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…
munmap(raw, mmap_size);

(void) munmap(raw, mmap_size);

Done.


src/flush.c, line 85 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…
munmap(raw, mmap_size);

.

Done.


tests/unit/common/mocks-stdlib.h, line 11 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…
posix_memalign_args

do we need this?

Yes, integration tests use it.


tests/unit/common/mocks-stdlib.c, line 36 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…
__wrap_posix_memalign

Is it still in use in any UT?

Yes, integration tests use it.


tests/unit/flush/flush-new.c, line 57 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…
posix_memalign_ENOMEM

mmap_ENOMEM

Done.

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch 2 times, most recently from b4e7f76 to d9217ed Compare February 10, 2021 11:04
Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 16 files reviewed, 6 unresolved discussions (waiting on @grom72)


src/flush.h, line 37 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…
RPMA_E_INVAL

Is there any UT for RPMA_E_INVAL return value?

Added

@ldorau
Copy link
Member Author

ldorau commented Feb 10, 2021

@grom72

Shall we also fix malloc_aligned() in example/common/common-conn.c?
or in the context of @pbalcer 's suggestion shall we have common utils function in librpma API that is used in examples as well as in the library (flush_apm_new)?

  1. malloc_aligned() in example/common/common-conn.c does not need any fix - those examples do not use fork()
  2. We do not need any until function for fork() as for now.

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from d9217ed to 7ce8eb2 Compare February 10, 2021 11:26
@ldorau
Copy link
Member Author

ldorau commented Feb 10, 2021

Description added and undrafted.

@ldorau ldorau marked this pull request as ready for review February 10, 2021 11:29
@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from 7ce8eb2 to 494a8e2 Compare February 10, 2021 11:30
Copy link
Contributor

@grom72 grom72 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r3, 1 of 1 files at r4.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @ldorau)


tests/unit/common/mocks-stdlib.h, line 11 at r2 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

Yes, integration tests use it.

but there is a definition in tests/integration/common/mocks.h
This file is used only by UTs


tests/unit/common/mocks-stdlib.c, line 36 at r2 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

Yes, integration tests use it.

.

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from 494a8e2 to e21b7b4 Compare February 10, 2021 12:49
@codecov-io
Copy link

codecov-io commented Feb 10, 2021

Codecov Report

Merging #866 (1cb0f35) into master (d9fb10a) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #866   +/-   ##
=======================================
  Coverage   99.83%   99.83%           
=======================================
  Files          15       15           
  Lines        1215     1220    +5     
=======================================
+ Hits         1213     1218    +5     
  Misses          2        2           

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 14 of 16 files reviewed, 2 unresolved discussions (waiting on @grom72)


tests/unit/common/mocks-stdlib.h, line 11 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…

but there is a definition in tests/integration/common/mocks.h
This file is used only by UTs

You are right, removed


tests/unit/common/mocks-stdlib.c, line 36 at r2 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…

.

Done.

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 14 of 16 files reviewed, 3 unresolved discussions (waiting on @grom72)

a discussion (no related file):
Unit tests for rpma_flush_delete() will be added


Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 14 of 16 files reviewed, 3 unresolved discussions (waiting on @grom72)


tests/unit/common/mocks-stdlib.h, line 11 at r2 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

You are right, removed

Done.

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 15 files at r1, 1 of 1 files at r2, 1 of 2 files at r3.
Reviewable status: 14 of 16 files reviewed, 5 unresolved discussions (waiting on @grom72 and @ldorau)


src/flush.h, line 37 at r5 (raw file):

 *
 * - RPMA_E_PROVIDER - ibv_dereg_mr() failed
 * - RPMA_E_INVAL - munmap() failed

This new error may be passed to the user level when it is called from rpma_conn_delete(). Please update the librpma.h accordingly.


src/flush.c, line 69 at r5 (raw file):

	/* allocate memory for the read-after-write buffer (RAW) */
	void *raw = mmap(NULL, mmap_size, PROT_READ | PROT_WRITE,

PROT_READ is not enough?

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 15 files at r1, 1 of 2 files at r3, 1 of 1 files at r4, 2 of 2 files at r5.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @grom72 and @ldorau)


tests/unit/common/mocks-stdlib.c, line 61 at r5 (raw file):

	(void) __len; /* unsused */

	test_free(__addr);

It seems we can validate the addr and len here.


tests/unit/common/mocks-stdlib.c, line 63 at r5 (raw file):

	test_free(__addr);

	return 0;

Do we have a negative scenario for munmap()?


tests/unit/flush/flush-new.c, line 57 at r5 (raw file):

/*
 * new__apm_mmap_ENOMEM -- malloc() fail with ENOMEM

malloc?

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 15 files at r1.
Reviewable status: all files reviewed, 9 unresolved discussions (waiting on @grom72 and @ldorau)


tests/integration/common/mocks.c, line 793 at r5 (raw file):

	(void) __len; /* unsused */

	test_free(__addr);

Can we validate addr and len here?

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

Reviewed 6 of 15 files at r1.
Reviewable status: all files reviewed, 15 unresolved discussions (waiting on @grom72 and @ldorau)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

	struct mmap_args allocated_raw = {0};
	will_return(__wrap_mmap, &allocated_raw);
	will_return(__wrap_mmap, &allocated_raw);

Why it is called twice?


tests/integration/example-01-connection/example-01-connection.c, line 250 at r5 (raw file):

	struct mmap_args allocated_raw = {0};
	will_return(__wrap_mmap, &allocated_raw);
	will_return(__wrap_mmap, &allocated_raw);

.


tests/integration/example-02-read-to-volatile/example-02-read-to-volatile.c, line 112 at r5 (raw file):

	struct mmap_args allocated_raw = {0};
	will_return(__wrap_mmap, &allocated_raw);
	will_return(__wrap_mmap, &allocated_raw);

Why twice?


tests/integration/example-02-read-to-volatile/example-02-read-to-volatile.c, line 310 at r5 (raw file):

	struct mmap_args allocated_raw = {0};
	will_return(__wrap_mmap, &allocated_raw);
	will_return(__wrap_mmap, &allocated_raw);

.


tests/integration/example-04-write-to-persistent/example-04-write-to-persistent.c, line 116 at r5 (raw file):

	struct mmap_args flush = {0};
	will_return(__wrap_mmap, &flush);
	will_return(__wrap_mmap, &flush);

Twice?


tests/integration/example-04-write-to-persistent/example-04-write-to-persistent.c, line 347 at r5 (raw file):

	struct mmap_args allocated_raw = {0};
	will_return(__wrap_mmap, &allocated_raw);
	will_return(__wrap_mmap, &allocated_raw);

.

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from e21b7b4 to d240e00 Compare February 10, 2021 14:27
Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 17 files reviewed, 14 unresolved discussions (waiting on @grom72, @janekmi, and @ldorau)

a discussion (no related file):

Previously, ldorau (Lukasz Dorau) wrote…

Unit tests for rpma_flush_delete() will be added

Added.


Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 17 files reviewed, 14 unresolved discussions (waiting on @grom72, @janekmi, and @ldorau)


tests/unit/flush/flush-new.c, line 57 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

malloc?

Done.

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 17 files reviewed, 14 unresolved discussions (waiting on @grom72, @janekmi, and @ldorau)


src/flush.c, line 69 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

PROT_READ is not enough?

No, ibv_reg_mr() requires PROT_WRITE.

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 17 files reviewed, 14 unresolved discussions (waiting on @grom72, @janekmi, and @ldorau)


src/flush.c, line 69 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

No, ibv_reg_mr() requires PROT_WRITE.

Done.


tests/unit/common/mocks-stdlib.c, line 63 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Do we have a negative scenario for munmap()?

Yes - delete__apm_munmap_E_INVAL

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

Reviewed 4 of 4 files at r6.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @grom72 and @ldorau)


src/flush.c, line 69 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

Done.

It is interesting. Did you get this from documentation or by experience? What is the error in this case?

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from d240e00 to 11c9a6c Compare February 10, 2021 15:16
Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 8 of 19 files reviewed, 12 unresolved discussions (waiting on @grom72, @janekmi, and @ldorau)


src/flush.h, line 37 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

This new error may be passed to the user level when it is called from rpma_conn_delete(). Please update the librpma.h accordingly.

Done.


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Why it is called twice?

cmocka needs it for unknown reason ... :-/


tests/unit/common/mocks-stdlib.c, line 61 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

It seems we can validate the addr and len here.

Done.

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

Reviewed 11 of 11 files at r7.
Reviewable status: all files reviewed, 10 unresolved discussions (waiting on @grom72 and @ldorau)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

cmocka needs it for unknown reason ... :-/

Can you set a breakpoint in the __wrap_mmap function and you see it being called twice?


tests/unit/flush/flush-common.h, line 27 at r7 (raw file):

struct flush_test_state {
	struct rpma_flush *flush;
	struct mmap_args allocated_raw;

Good idea!

Copy link
Contributor

@grom72 grom72 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 4 files at r6, 1 of 11 files at r7.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @ldorau)

Copy link
Contributor

@grom72 grom72 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 11 files at r7.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @ldorau)

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @janekmi and @ldorau)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Can you set a breakpoint in the __wrap_mmap function and you see it being called twice?

I did it long ago :-) It is hit only once of course, but if there is only one line, cmocka doesn't seem to see it. Apparently I will have to debug cmocka later ....


tests/integration/example-01-connection/example-01-connection.c, line 250 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

.

.


tests/integration/example-02-read-to-volatile/example-02-read-to-volatile.c, line 112 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Why twice?

.


tests/integration/example-02-read-to-volatile/example-02-read-to-volatile.c, line 310 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

.

.


tests/integration/example-04-write-to-persistent/example-04-write-to-persistent.c, line 116 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Twice?

.


tests/integration/example-04-write-to-persistent/example-04-write-to-persistent.c, line 347 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

.

.

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @janekmi)


src/flush.c, line 69 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

It is interesting. Did you get this from documentation or by experience? What is the error in this case?

From test - EINVAL


tests/integration/common/mocks.c, line 793 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

Can we validate addr and len here?

Yes. Done.

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from 11c9a6c to 356a8cc Compare February 11, 2021 08:41
Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 19 files reviewed, 8 unresolved discussions (waiting on @grom72 and @janekmi)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

I did it long ago :-) It is hit only once of course, but if there is only one line, cmocka doesn't seem to see it. Apparently I will have to debug cmocka later ....

When there is only one such line, I get the error:

[ RUN      ] test_client__success
[  ERROR   ] --- No entries for symbol __wrap_mmap.
tests/integration/common/mocks.c:775: error: Could not get value to mock function __wrap_mmap
tests/integration/example-01-connection/example-01-connection.c:96: note: Previously returned mock value was declared here
[  FAILED  ] test_client__success

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 19 files reviewed, 8 unresolved discussions (waiting on @grom72 and @janekmi)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

When there is only one such line, I get the error:

[ RUN      ] test_client__success
[  ERROR   ] --- No entries for symbol __wrap_mmap.
tests/integration/common/mocks.c:775: error: Could not get value to mock function __wrap_mmap
tests/integration/example-01-connection/example-01-connection.c:96: note: Previously returned mock value was declared here
[  FAILED  ] test_client__success

The same on CI: https://github.com/ldorau/rpma/runs/1877956647?check_suite_focus=true

Copy link
Contributor

@grom72 grom72 left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 11 files at r7, 3 of 6 files at r8.
Reviewable status: 16 of 19 files reviewed, 8 unresolved discussions (waiting on @grom72 and @janekmi)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

When there is only one such line, I get the error:

[ RUN      ] test_client__success
[  ERROR   ] --- No entries for symbol __wrap_mmap.
tests/integration/common/mocks.c:775: error: Could not get value to mock function __wrap_mmap
tests/integration/example-01-connection/example-01-connection.c:96: note: Previously returned mock value was declared here
[  FAILED  ] test_client__success

Does it mean that somebody else calls mmap()?

Copy link
Contributor

@grom72 grom72 left a comment

Choose a reason for hiding this comment

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

Reviewed 1 of 11 files at r7, 3 of 6 files at r8.
Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @janekmi)

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @janekmi)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, grom72 (Tomasz Gromadzki) wrote…

Does it mean that somebody else calls mmap()?

Maybe cmocka? :-)

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @janekmi)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

Maybe cmocka? :-)

I will debug it.

Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 8 unresolved discussions (waiting on @janekmi)


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

I will debug it.

What a blindness ... I already know ...

@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from 356a8cc to 1cb0f35 Compare February 11, 2021 09:49
Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: 13 of 19 files reviewed, 8 unresolved discussions (waiting on @grom72 and @janekmi)


src/flush.c, line 69 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

From test - EINVAL

Done.


tests/integration/example-01-connection/example-01-connection.c, line 97 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

What a blindness ... I already know ...

Fixed.

Done.


tests/integration/example-01-connection/example-01-connection.c, line 250 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

.

Done.


tests/integration/example-02-read-to-volatile/example-02-read-to-volatile.c, line 112 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

.

Done.


tests/integration/example-02-read-to-volatile/example-02-read-to-volatile.c, line 310 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

.

Done.


tests/integration/example-04-write-to-persistent/example-04-write-to-persistent.c, line 116 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

.

Done.


tests/integration/example-04-write-to-persistent/example-04-write-to-persistent.c, line 347 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

.

Done.

Copy link

@janekmi janekmi left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 6 files at r8, 6 of 6 files at r9.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ldorau)


src/flush.c, line 69 at r5 (raw file):

Previously, ldorau (Lukasz Dorau) wrote…

Done.

It looks like an undocumented feature. 🤔

The memory region passed to rpma_mr_reg() (ibv_mr_reg())
cannot be allocated from the heap (using malloc()
or posix_memalign()), but should be mapped using mmap().

Rationale:

If ibv_fork_init() was called, the memory region
passed to ibv_mr_reg() is marked by this function
with flag “do not copy on fork”
and after having called fork(), the child process
does not receive this range of virtual addresses.
If this memory region was allocated from the heap,
the child process receives a corrupted heap
with a “hole” of inaccessible addresses inside.
A memory allocator knows nothing about this “hole”
and if it tries to access (read or write)
that range of virtual addresses, it causes a segfault.

Ref: pmem#751
@ldorau ldorau force-pushed the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch from 1cb0f35 to 5ef2a8d Compare February 11, 2021 10:07
Copy link
Member Author

@ldorau ldorau left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ldorau)


src/flush.c, line 69 at r5 (raw file):

Previously, janekmi (Jan Michalski) wrote…

It looks like an undocumented feature. 🤔

In rdma-core/libibverbs/cmd_ioctl.c :

147│         if (ioctl(context->cmd_fd, RDMA_VERBS_IOCTL, &cmd->hdr))
148├───────────────> return errno;

returns errno = 22 (EINVAL)

Copy link
Contributor

@osalyk osalyk left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ldorau)

@ldorau ldorau merged commit fbac593 into pmem:master Feb 11, 2021
@ldorau ldorau deleted the rpma-mmap-memory-for-rpma_mr_reg-in-rpma_flush_apm_new branch February 11, 2021 11:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants