All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Paul E. McKenney" <paulmck@linux.ibm.com>
To: Junchang Wang <junchangwang@gmail.com>
Cc: perfbook@vger.kernel.org
Subject: Re: [PATCH 0/3] Patches for Section Deferred Processing
Date: Sat, 24 Nov 2018 08:47:41 -0800	[thread overview]
Message-ID: <20181124164741.GX4170@linux.ibm.com> (raw)
In-Reply-To: <1543052094-8306-1-git-send-email-junchangwang@gmail.com>

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;
 	}
 
 	/*


  parent reply	other threads:[~2018-11-25  3:36 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Paul E. McKenney [this message]
2018-11-25  2:18   ` [PATCH 0/3] Patches for Section Deferred Processing Junchang Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181124164741.GX4170@linux.ibm.com \
    --to=paulmck@linux.ibm.com \
    --cc=junchangwang@gmail.com \
    --cc=perfbook@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.