On Tue, Mar 01, 2016 at 07:38:00PM +0100, Nahim El Atmani wrote:
> * strace.c: alloctcb() when no tcbs are available (first call and subsequent
> calls when tcbtab is full) call expand_tcbtab(). Now, expand_tcbtab() allocate
> the minimum required amount of memory to create the tcbtab if needed and 
> expend
> otherwise instead of relying on the preallocation of a large amount of tcbs
> and expand if needed.

Now that the patch is almost ready, it's time to comment this commit
message.  The requirement is that after a summary and optional few lines
of text describing the change goes a ChangeLog-style entry (described in
detail e.g. at
https://www.gnu.org/prep/standards/html_node/Style-of-Change-Logs.html)

For example, a ChangeLog-style entry might be something like this:

* strace.c (expand_tcbtab): Do initial memory allocation when
tcbtabsize == 0.
(init): Remove initial memory allocation for tcbtab.

> -     unsigned int i = tcbtabsize;
> -     struct tcb *newtcbs = xcalloc(tcbtabsize, sizeof(newtcbs[0]));
> -     struct tcb **newtab = xreallocarray(tcbtab, tcbtabsize * 2,
> -                                         sizeof(tcbtab[0]));
> -     tcbtabsize *= 2;
> +     unsigned int i, new_tcbtabsize, alloc_tcbtabsize;
> +     struct tcb *newtcbs;
> +     struct tcb **newtab;
> +
> +     if (tcbtabsize) {
> +             alloc_tcbtabsize = tcbtabsize;
> +             new_tcbtabsize = tcbtabsize * 2;
> +     } else {
> +             new_tcbtabsize = alloc_tcbtabsize = 1;
> +     }
> +
> +     i = tcbtabsize;
> +     newtcbs = xcalloc(alloc_tcbtabsize, sizeof(newtcbs[0]));
> +     newtab = xreallocarray(tcbtab, new_tcbtabsize, sizeof(tcbtab[0]));
> +     tcbtabsize = new_tcbtabsize;
>       tcbtab = newtab;
>       while (i < tcbtabsize)
>               tcbtab[i++] = newtcbs++;

You can safely get rid of newtab, it is no longer needed after
commit v4.10-75-g3e9d71f.  Unfortunately, I missed the opportunity
to eliminate it along with that commit.

You can also write this code without using "i" if you like, e.g.

        newtcbs = xcalloc(alloc_tcbtabsize, sizeof(newtcbs[0]));
        tcbtab = xreallocarray(tcbtab, new_tcbtabsize, sizeof(tcbtab[0]));
        while (tcbtabsize < new_tcbtabsize)
                tcbtab[tcbtabsize++] = newtcbs++;


-- 
ldv

Attachment: pgpTUP7SDWUIK.pgp
Description: PGP signature

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Strace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to