All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] Patches for Section Deferred Processing
@ 2018-11-24  9:34 Junchang Wang
  2018-11-24  9:34 ` [PATCH 1/3] route_hazptr: Add dependency to hazptr Junchang Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Junchang Wang @ 2018-11-24  9:34 UTC (permalink / raw)
  To: paulmck; +Cc: perfbook, Junchang Wang

Hi Paul,

This is the patch sets for Section Deferred Processing. Please take a look.

The first patch fixes a dependency issue in compiling route_hazptr.c.

The second patch fixes a memory leak bug in hazptr.c.

The last one fixes a typo in writing.


Thanks,
--Junchang

Junchang Wang (3):
  route_hazptr: Add dependency to hazptr
  route_hazptr: Fix a memory leak bug
  defer: Fix a typo

 CodeSamples/defer/Makefile | 2 +-
 CodeSamples/defer/hazptr.c | 4 ++++
 defer/hazptr.tex           | 2 +-
 3 files changed, 6 insertions(+), 2 deletions(-)

-- 
2.7.4


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

* [PATCH 1/3] route_hazptr: Add dependency to hazptr
  2018-11-24  9:34 [PATCH 0/3] Patches for Section Deferred Processing Junchang Wang
@ 2018-11-24  9:34 ` Junchang Wang
  2018-11-24  9:34 ` [PATCH 2/3] route_hazptr: Fix a memory leak bug Junchang Wang
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Junchang Wang @ 2018-11-24  9:34 UTC (permalink / raw)
  To: paulmck; +Cc: perfbook, Junchang Wang

Target route_hazptr depends on hazptr.c and hazptr.h. So add this dependency to Makefile.

Signed-off-by: Junchang Wang <junchangwang@gmail.com>
---
 CodeSamples/defer/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CodeSamples/defer/Makefile b/CodeSamples/defer/Makefile
index 5a08c1f..270c151 100644
--- a/CodeSamples/defer/Makefile
+++ b/CodeSamples/defer/Makefile
@@ -123,7 +123,7 @@ rcu_sig: rcu_sig.c rcu_sig.h ../api.h rcutorture.h
 rcu_ts: rcu_ts.c rcu_ts.h ../api.h rcutorture.h
 	cc $(GCC_ARGS) -o rcu_ts -DTEST rcu_ts.c -lpthread
 
-route_hazptr: route_hazptr.c ../api.h ../lib/random.h ../lib/random.c routetorture.h
+route_hazptr: route_hazptr.c hazptr.c hazptr.h ../api.h ../lib/random.h ../lib/random.c routetorture.h
 	cc $(GCC_ARGS) -o route_hazptr route_hazptr.c hazptr.c ../lib/random.c -lpthread
 
 route_rcu: route_rcu.c ../api.h ../lib/random.h ../lib/random.c routetorture.h
-- 
2.7.4


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

* [PATCH 2/3] route_hazptr: Fix a memory leak bug
  2018-11-24  9:34 [PATCH 0/3] Patches for Section Deferred Processing Junchang Wang
  2018-11-24  9:34 ` [PATCH 1/3] route_hazptr: Add dependency to hazptr Junchang Wang
@ 2018-11-24  9:34 ` Junchang Wang
  2018-11-24  9:34 ` [PATCH 3/3] defer: Fix a typo Junchang Wang
  2018-11-24 16:47 ` [PATCH 0/3] Patches for Section Deferred Processing Paul E. McKenney
  3 siblings, 0 replies; 6+ messages in thread
From: Junchang Wang @ 2018-11-24  9:34 UTC (permalink / raw)
  To: paulmck; +Cc: perfbook, Junchang Wang

Global pointer gplist is used to record hazard pointer array once it's
allocated. This can avoid allocating and freeing hazptr array each time
function hazptr_scan() is invoked. This patch fixes a memory leak bug and
helps achieve the design goal.

Signed-off-by: Junchang Wang <junchangwang@gmail.com>
---
 CodeSamples/defer/hazptr.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/CodeSamples/defer/hazptr.c b/CodeSamples/defer/hazptr.c
index 91df310..061ca2c 100644
--- a/CodeSamples/defer/hazptr.c
+++ b/CodeSamples/defer/hazptr.c
@@ -53,6 +53,9 @@ void hazptr_thread_exit(void)
 		hazptr_scan();
 		poll(NULL, 0, 1);
 	}
+
+	if (gplist != NULL)
+		free(gplist);
 }
 
 void hazptr_reinitialize()
@@ -103,6 +106,7 @@ void hazptr_scan()
 			fprintf(stderr, "hazptr_scan: out of memory\n");
 			exit(EXIT_FAILURE);
 		}
+		gplist = plist;
 	}
 
 	/*
-- 
2.7.4


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

* [PATCH 3/3] defer: Fix a typo
  2018-11-24  9:34 [PATCH 0/3] Patches for Section Deferred Processing Junchang Wang
  2018-11-24  9:34 ` [PATCH 1/3] route_hazptr: Add dependency to hazptr Junchang Wang
  2018-11-24  9:34 ` [PATCH 2/3] route_hazptr: Fix a memory leak bug Junchang Wang
@ 2018-11-24  9:34 ` Junchang Wang
  2018-11-24 16:47 ` [PATCH 0/3] Patches for Section Deferred Processing Paul E. McKenney
  3 siblings, 0 replies; 6+ messages in thread
From: Junchang Wang @ 2018-11-24  9:34 UTC (permalink / raw)
  To: paulmck; +Cc: perfbook, Junchang Wang

Signed-off-by: Junchang Wang <junchangwang@gmail.com>
---
 defer/hazptr.tex | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/defer/hazptr.tex b/defer/hazptr.tex
index 346146f..09c5f21 100644
--- a/defer/hazptr.tex
+++ b/defer/hazptr.tex
@@ -91,7 +91,7 @@ recorded a hazard pointer for the data element.
 	It might be inefficient in some sense, but the fact is that
 	such restarting is absolutely required for correctness.
 	To see this, consider a hazard-pointer-protected linked list
-	containing elements~A, B, and~C that is subjecte to the
+	containing elements~A, B, and~C that is subjected to the
 	following sequence of events:
 
 	\begin{enumerate}
-- 
2.7.4


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

* Re: [PATCH 0/3] Patches for Section Deferred Processing
  2018-11-24  9:34 [PATCH 0/3] Patches for Section Deferred Processing Junchang Wang
                   ` (2 preceding siblings ...)
  2018-11-24  9:34 ` [PATCH 3/3] defer: Fix a typo Junchang Wang
@ 2018-11-24 16:47 ` Paul E. McKenney
  2018-11-25  2:18   ` Junchang Wang
  3 siblings, 1 reply; 6+ messages in thread
From: Paul E. McKenney @ 2018-11-24 16:47 UTC (permalink / raw)
  To: Junchang Wang; +Cc: perfbook

On Sat, Nov 24, 2018 at 05:34:51PM +0800, Junchang Wang wrote:
> Hi Paul,
> 
> This is the patch sets for Section Deferred Processing. Please take a look.
> 
> The first patch fixes a dependency issue in compiling route_hazptr.c.
> 
> The second patch fixes a memory leak bug in hazptr.c.
> 
> The last one fixes a typo in writing.
> 
> 
> Thanks,
> --Junchang

Good catches, applied, thank you!

On the memory-leak bug, I removed the "if" due to POSIX specifying
that free() is a no-op when given a NULL pointer.

	http://pubs.opengroup.org/onlinepubs/009695399/functions/free.html

Please see below for the updated commit, and please let me know if I
messed anything up.

						Thanx, Paul

> Junchang Wang (3):
>   route_hazptr: Add dependency to hazptr
>   route_hazptr: Fix a memory leak bug
>   defer: Fix a typo
> 
>  CodeSamples/defer/Makefile | 2 +-
>  CodeSamples/defer/hazptr.c | 4 ++++
>  defer/hazptr.tex           | 2 +-
>  3 files changed, 6 insertions(+), 2 deletions(-)

------------------------------------------------------------------------

commit b8c1647f53ddedf10bf2973371f6f685dfd31d62
Author: Junchang Wang <junchangwang@gmail.com>
Date:   Sat Nov 24 17:34:53 2018 +0800

    route_hazptr: Fix a memory leak bug
    
    Global pointer gplist is used to record hazard pointer array once it's
    allocated. This can avoid allocating and freeing hazptr array each time
    function hazptr_scan() is invoked. This patch fixes a memory leak bug and
    helps achieve the design goal.
    
    Signed-off-by: Junchang Wang <junchangwang@gmail.com>
    [ paulmck: Remove redundant "if" because free() ignores NULL argument. ]
    Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>

diff --git a/CodeSamples/defer/hazptr.c b/CodeSamples/defer/hazptr.c
index 91df310e24a2..fdb387e59ea1 100644
--- a/CodeSamples/defer/hazptr.c
+++ b/CodeSamples/defer/hazptr.c
@@ -53,6 +53,8 @@ void hazptr_thread_exit(void)
 		hazptr_scan();
 		poll(NULL, 0, 1);
 	}
+
+	free(gplist);
 }
 
 void hazptr_reinitialize()
@@ -103,6 +105,7 @@ void hazptr_scan()
 			fprintf(stderr, "hazptr_scan: out of memory\n");
 			exit(EXIT_FAILURE);
 		}
+		gplist = plist;
 	}
 
 	/*


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

* Re: [PATCH 0/3] Patches for Section Deferred Processing
  2018-11-24 16:47 ` [PATCH 0/3] Patches for Section Deferred Processing Paul E. McKenney
@ 2018-11-25  2:18   ` Junchang Wang
  0 siblings, 0 replies; 6+ messages in thread
From: Junchang Wang @ 2018-11-25  2:18 UTC (permalink / raw)
  To: Paul McKenney; +Cc: perfbook

On Sun, Nov 25, 2018 at 12:47 AM Paul E. McKenney <paulmck@linux.ibm.com> wrote:
>
> On Sat, Nov 24, 2018 at 05:34:51PM +0800, Junchang Wang wrote:
> > Hi Paul,
> >
> > This is the patch sets for Section Deferred Processing. Please take a look.
> >
> > The first patch fixes a dependency issue in compiling route_hazptr.c.
> >
> > The second patch fixes a memory leak bug in hazptr.c.
> >
> > The last one fixes a typo in writing.
> >
> >
> > Thanks,
> > --Junchang
>
> Good catches, applied, thank you!
>
> On the memory-leak bug, I removed the "if" due to POSIX specifying
> that free() is a no-op when given a NULL pointer.
>
>         http://pubs.opengroup.org/onlinepubs/009695399/functions/free.html
>
> Please see below for the updated commit, and please let me know if I
> messed anything up.
>

That's right. Thanks a lot for the comment and link :-).


Thanks,
--Junchang


>                                                 Thanx, Paul
>
> > Junchang Wang (3):
> >   route_hazptr: Add dependency to hazptr
> >   route_hazptr: Fix a memory leak bug
> >   defer: Fix a typo
> >
> >  CodeSamples/defer/Makefile | 2 +-
> >  CodeSamples/defer/hazptr.c | 4 ++++
> >  defer/hazptr.tex           | 2 +-
> >  3 files changed, 6 insertions(+), 2 deletions(-)
>
> ------------------------------------------------------------------------
>
> commit b8c1647f53ddedf10bf2973371f6f685dfd31d62
> Author: Junchang Wang <junchangwang@gmail.com>
> Date:   Sat Nov 24 17:34:53 2018 +0800
>
>     route_hazptr: Fix a memory leak bug
>
>     Global pointer gplist is used to record hazard pointer array once it's
>     allocated. This can avoid allocating and freeing hazptr array each time
>     function hazptr_scan() is invoked. This patch fixes a memory leak bug and
>     helps achieve the design goal.
>
>     Signed-off-by: Junchang Wang <junchangwang@gmail.com>
>     [ paulmck: Remove redundant "if" because free() ignores NULL argument. ]
>     Signed-off-by: Paul E. McKenney <paulmck@linux.ibm.com>
>
> diff --git a/CodeSamples/defer/hazptr.c b/CodeSamples/defer/hazptr.c
> index 91df310e24a2..fdb387e59ea1 100644
> --- a/CodeSamples/defer/hazptr.c
> +++ b/CodeSamples/defer/hazptr.c
> @@ -53,6 +53,8 @@ void hazptr_thread_exit(void)
>                 hazptr_scan();
>                 poll(NULL, 0, 1);
>         }
> +
> +       free(gplist);
>  }
>
>  void hazptr_reinitialize()
> @@ -103,6 +105,7 @@ void hazptr_scan()
>                         fprintf(stderr, "hazptr_scan: out of memory\n");
>                         exit(EXIT_FAILURE);
>                 }
> +               gplist = plist;
>         }
>
>         /*
>


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

end of thread, other threads:[~2018-11-25  3:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-24  9:34 [PATCH 0/3] Patches for Section Deferred Processing Junchang Wang
2018-11-24  9:34 ` [PATCH 1/3] route_hazptr: Add dependency to hazptr Junchang Wang
2018-11-24  9:34 ` [PATCH 2/3] route_hazptr: Fix a memory leak bug Junchang Wang
2018-11-24  9:34 ` [PATCH 3/3] defer: Fix a typo Junchang Wang
2018-11-24 16:47 ` [PATCH 0/3] Patches for Section Deferred Processing Paul E. McKenney
2018-11-25  2:18   ` Junchang Wang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.