linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12 10:45 Deming Wang
  2023-04-12 12:30 ` David Hildenbrand
  0 siblings, 1 reply; 6+ messages in thread
From: Deming Wang @ 2023-04-12 10:45 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign()

As a pointer is passed into posix_memalign(), initialize *one_page
to NULL to silence a warning about the function's return value being
used as uninitialized (which is not valid anyway because the error
is properly checked before p is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index cbb5e6893cbf..94c7dffc4d7d 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -96,10 +96,10 @@ void split_pmd_thp(void)
 	char *one_page;
 	size_t len = 4 * pmd_pagesize;
 	size_t i;
+	int ret;
 
-	one_page = memalign(pmd_pagesize, len);
-
-	if (!one_page) {
+	ret = posix_memalign((void **)&one_page, pmd_pagesize, len);
+	if (ret < 0) {
 		printf("Fail to allocate memory\n");
 		exit(EXIT_FAILURE);
 	}
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign()
  2023-04-12 10:45 [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign() Deming Wang
@ 2023-04-12 12:30 ` David Hildenbrand
  0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2023-04-12 12:30 UTC (permalink / raw)
  To: Deming Wang, akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel

On 12.04.23 12:45, Deming Wang wrote:
> memalign() is obsolete according to its manpage.
> 
> Replace memalign() with posix_memalign()
> 
> As a pointer is passed into posix_memalign(), initialize *one_page
> to NULL to silence a warning about the function's return value being

Where is the initialization to NULL done below?

> used as uninitialized (which is not valid anyway because the error
> is properly checked before p is returned).

"p" ?

> 
> Signed-off-by: Deming Wang <wangdeming@inspur.com>
> ---
>   tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index cbb5e6893cbf..94c7dffc4d7d 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -96,10 +96,10 @@ void split_pmd_thp(void)
>   	char *one_page;
>   	size_t len = 4 * pmd_pagesize;
>   	size_t i;
> +	int ret;
>   
> -	one_page = memalign(pmd_pagesize, len);
> -
> -	if (!one_page) {
> +	ret = posix_memalign((void **)&one_page, pmd_pagesize, len);
> +	if (ret < 0) {
>   		printf("Fail to allocate memory\n");
>   		exit(EXIT_FAILURE);
>   	}

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign()
  2023-04-13  1:17 Deming Wang
@ 2023-04-13 11:57 ` David Hildenbrand
  0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2023-04-13 11:57 UTC (permalink / raw)
  To: Deming Wang, akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel

On 13.04.23 03:17, Deming Wang wrote:
> memalign() is obsolete according to its manpage.
> 
> Replace memalign() with posix_memalign()
> 
> As a pointer is passed into posix_memalign(), initialize *one_page
> to NULL to silence a warning about the function's return value being
> used as uninitialized (which is not valid anyway because the error
> is properly checked before one_page is returned).

^ I'm getting tired of pointing out the same thing.

Please collect similar patches and send them as a series; and stop
copy-pasting the same thing into all of the similar patches you send.

Last but not least, tag you patches accordingly: "selftests/mm: 
split_huge_page_test: ..."

> 
> Signed-off-by: Deming Wang <wangdeming@inspur.com>
> ---
>   tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index cbb5e6893cbf..94c7dffc4d7d 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -96,10 +96,10 @@ void split_pmd_thp(void)
>   	char *one_page;
>   	size_t len = 4 * pmd_pagesize;
>   	size_t i;
> +	int ret;
>   
> -	one_page = memalign(pmd_pagesize, len);
> -
> -	if (!one_page) {
> +	ret = posix_memalign((void **)&one_page, pmd_pagesize, len);
> +	if (ret < 0) {
>   		printf("Fail to allocate memory\n");
>   		exit(EXIT_FAILURE);
>   	}

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign()
@ 2023-04-13  1:17 Deming Wang
  2023-04-13 11:57 ` David Hildenbrand
  0 siblings, 1 reply; 6+ messages in thread
From: Deming Wang @ 2023-04-13  1:17 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign()

As a pointer is passed into posix_memalign(), initialize *one_page
to NULL to silence a warning about the function's return value being
used as uninitialized (which is not valid anyway because the error
is properly checked before one_page is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index cbb5e6893cbf..94c7dffc4d7d 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -96,10 +96,10 @@ void split_pmd_thp(void)
 	char *one_page;
 	size_t len = 4 * pmd_pagesize;
 	size_t i;
+	int ret;
 
-	one_page = memalign(pmd_pagesize, len);
-
-	if (!one_page) {
+	ret = posix_memalign((void **)&one_page, pmd_pagesize, len);
+	if (ret < 0) {
 		printf("Fail to allocate memory\n");
 		exit(EXIT_FAILURE);
 	}
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign()
  2023-04-12  7:49 Deming Wang
@ 2023-04-12  8:27 ` David Hildenbrand
  0 siblings, 0 replies; 6+ messages in thread
From: David Hildenbrand @ 2023-04-12  8:27 UTC (permalink / raw)
  To: Deming Wang, akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel

On 12.04.23 09:49, Deming Wang wrote:
> memalign() is obsolete according to its manpage.
> 
> Replace memalign() with posix_memalign() and remove malloc.h include
> that was there for memalign().

Comment does not apply.

> 
> As a pointer is passed into posix_memalign(), initialize *p to NULL
> to silence a warning about the function's return value being used as
> uninitialized (which is not valid anyway because the error is properly
> checked before p is returned).

Comment does not apply.

> 
> Signed-off-by: Deming Wang <wangdeming@inspur.com>
> ---
>   tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
> index cbb5e6893cbf..8f48f07bc821 100644
> --- a/tools/testing/selftests/mm/split_huge_page_test.c
> +++ b/tools/testing/selftests/mm/split_huge_page_test.c
> @@ -96,10 +96,10 @@ void split_pmd_thp(void)
>   	char *one_page;
>   	size_t len = 4 * pmd_pagesize;
>   	size_t i;
> +	int ret;
>   
> -	one_page = memalign(pmd_pagesize, len);
> -
> -	if (!one_page) {
> +	ret = posix_memalign((void **)(&one_page), pmd_pagesize, len);

ret = posix_memalign((void **)&one_page, pmd_pagesize, len);

Should do.

> +	if (ret < 0) {
>   		printf("Fail to allocate memory\n");
>   		exit(EXIT_FAILURE);
>   	}

-- 
Thanks,

David / dhildenb



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign()
@ 2023-04-12  7:49 Deming Wang
  2023-04-12  8:27 ` David Hildenbrand
  0 siblings, 1 reply; 6+ messages in thread
From: Deming Wang @ 2023-04-12  7:49 UTC (permalink / raw)
  To: akpm, shuah; +Cc: linux-mm, linux-kselftest, linux-kernel, Deming Wang

memalign() is obsolete according to its manpage.

Replace memalign() with posix_memalign() and remove malloc.h include
that was there for memalign().

As a pointer is passed into posix_memalign(), initialize *p to NULL
to silence a warning about the function's return value being used as
uninitialized (which is not valid anyway because the error is properly
checked before p is returned).

Signed-off-by: Deming Wang <wangdeming@inspur.com>
---
 tools/testing/selftests/mm/split_huge_page_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mm/split_huge_page_test.c b/tools/testing/selftests/mm/split_huge_page_test.c
index cbb5e6893cbf..8f48f07bc821 100644
--- a/tools/testing/selftests/mm/split_huge_page_test.c
+++ b/tools/testing/selftests/mm/split_huge_page_test.c
@@ -96,10 +96,10 @@ void split_pmd_thp(void)
 	char *one_page;
 	size_t len = 4 * pmd_pagesize;
 	size_t i;
+	int ret;
 
-	one_page = memalign(pmd_pagesize, len);
-
-	if (!one_page) {
+	ret = posix_memalign((void **)(&one_page), pmd_pagesize, len);
+	if (ret < 0) {
 		printf("Fail to allocate memory\n");
 		exit(EXIT_FAILURE);
 	}
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-04-13 11:57 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-12 10:45 [PATCH] mm: huge_memory: Replace obsolete memalign() with posix_memalign() Deming Wang
2023-04-12 12:30 ` David Hildenbrand
  -- strict thread matches above, loose matches on Subject: below --
2023-04-13  1:17 Deming Wang
2023-04-13 11:57 ` David Hildenbrand
2023-04-12  7:49 Deming Wang
2023-04-12  8:27 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).