[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ltp-list
Subject:    Re: [LTP]
From:       Crossover Lonely <crosslonelyover () gmail ! com>
Date:       2010-01-21 7:37:09
Message-ID: 5a774f4c1001202337p306b1f4bkd9406c6d6f32e87d () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Oh, I got it. There is some confusion.

1) In hugeshmget01.c, setup() will call
          tst_sig(NOFORK, DEF_HANDLER, cleanup);
2)  In include/test.h:
                /* defines for unexpected signal setup routine (set_usig.c)
*/
                #define FORK    1                    /* SIGCLD is to be
ignored */
                #define NOFORK  0               /* SIGCLD is to be caught */
     so here, hugeshmget01 want to catch SIGCLD.
3) In lib/tst_gig.c:
                ...
                case SIGCLD:
                        if (fork_flag == FORK || STD_COPIES > 1)
                                continue;

                default:
                        if (tst_setup_signal(sig, handler) == SIG_ERR)
                                tst_resm(TWARN | TERRNO,
                                        "signal() failed for signal %d",
sig);
                        break;
                ...

Here, if you donot use "-c Xnumber", the SIGCLD handler will be def_handler,
which will rise
             "Unexpected signal %d received"
when received signal SIGCLD
But if you use "-c Xnumber", STD_COPIES > 1 will be true, so the handler to
SIGCLD is default, "ignore".


Confusion comes out:
           1. tst_sig(NOFORK, DEF_HANDLER, cleanup);       /* SIGCLD is to
be caught */
           2. -c Xnumber will lead to SIGCLD ignored
Although the results are normal, but the code itself can lead to confusion.
So I suggest use the following patch:

--- hugeshmget01.c    2009-11-20 00:05:21.000000000 +0800
+++ hugeshmget01_1.c    2010-01-21 08:41:56.350057513 +0800
@@ -160,7 +160,7 @@
 setup(void)
 {
     /* capture signals */
-    tst_sig(NOFORK, DEF_HANDLER, cleanup);
+    tst_sig(FORK, DEF_HANDLER, cleanup);

     /* Pause if that option was specified */
     TEST_PAUSE;





2010/1/21 Crossover Lonely <crosslonelyover@gmail.com>

> Hi,
> I have tried "gdb ./hugeshmget01 -c 2" and "set follow-fork-mode
> child".
> Then I traced into the child thread, and got
> "hugeshmget01    1  TBROK  :  Unexpected signal 17 received."
> 
> 
> 
> 2010/1/21 liubo <liubo2009@cn.fujitsu.com>
> 
> > Hi,
> > 
> > The hugeshmget01 case is designed for testing standard SYSV shared
> > memory system calls "shmget", and it do need a few concurrent copies
> > in order to fulfill a multi-process memory-allocated environment.
> > 
> > IMO, "-c Xnumber" is needed.
> > 
> > Thanks,
> > Liu Bo
> > 
> > 
> > 
> > On 01/21/2010 10:14 AM, Crossover Lonely wrote:
> > 
> > It works!
> > But isn't weird? Why just use ./hugeshmget won't work?
> > I traced it, and found it calls tsg_sig() in setup():
> > tst_sig(NOFORK, DEF_HANDLER, cleanup);
> > and in tsg_sig():
> > ...
> > case SIGCLD:
> > if (fork_flag == FORK || STD_COPIES > 1)
> > continue;
> > 
> > default:
> > if (tst_setup_signal(sig, handler) == SIG_ERR)
> > tst_resm(TWARN | TERRNO,
> > "signal() failed for signal %d", sig);
> > break;
> > ...
> > 
> > so here  hugeshmget set its action to SIGCLD to handler - here is
> > def_handler(), which can
> > rise "Unexpected signal %d received." message when recived SIGCLD.
> > static void def_handler(int sig)
> > {
> > /*
> > * Break remaining test cases, do any cleanup, then exit
> > */
> > tst_brkm(TBROK, 0, "Unexpected signal %d received.", sig);
> > 
> > /* now cleanup and exit */
> > if (T_cleanup)
> > (*T_cleanup) ();
> > 
> > tst_exit();
> > }
> > 
> > So I think it's better to correct it!
> > 
> > Thanks and Best Regards,
> > shenghui
> > 
> > 2010/1/21 liubo <liubo2009@cn.fujitsu.com> <liubo2009@cn.fujitsu.com>
> > 
> > Hi,
> > 
> > In my box, I can add -c Xnumber to avoid the unexpect signal,
> > for example, ./hugeshmget -c 10. Maybe you can try this as well.
> > 
> > Thanks,
> > Liu Bo
> > 
> > 
> > On 01/21/2010 08:50 AM, Crossover Lonely wrote:
> > 
> > For your convenience, I just made to patches against the signle file, not
> > the whole directory.
> > 
> > solution 1=======================
> > --- hugeshmget01.c    2009-11-20 00:05:21.000000000 +0800
> > +++ hugeshmget01_2.c    2010-01-21 08:43:11.790533086 +0800
> > @@ -78,14 +78,14 @@
> > tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> > }
> > 
> > -    setup();            /* global setup */
> > -
> > /* The following loop checks looping state if -i option given */
> > if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
> > tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
> > sufficient availability of Hugepages on the system");
> > else
> > huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
> > hugepages_size() * 1024) / 2 ;
> > 
> > +    setup();            /* global setup */
> > +
> > for (lc = 0; TEST_LOOPING(lc); lc++) {
> > /* reset Tst_count in case we are looping */
> > Tst_count = 0;
> > 
> > 
> > solution 2=============================
> > =
> > --- hugeshmget01.c    2009-11-20 00:05:21.000000000 +0800
> > +++ hugeshmget01_1.c    2010-01-21 08:41:56.350057513 +0800
> > @@ -160,7 +160,7 @@
> > setup(void)
> > {
> > /* capture signals */
> > -    tst_sig(NOFORK, DEF_HANDLER, cleanup);
> > +    tst_sig(FORK, DEF_HANDLER, cleanup);
> > 
> > /* Pause if that option was specified */
> > TEST_PAUSE;
> > 
> > 
> > 2010/1/21 Crossover Lonely <crosslonelyover@gmail.com> \
> > <crosslonelyover@gmail.com> <crosslonelyover@gmail.com> \
> > <crosslonelyover@gmail.com> 
> > 
> > Hi all,
> > 
> > When the hugeshmget01 runs, it gets unexpected signal SIGCHLD/SIGCLD,
> > and thus stops immediately.
> > I found two ways to resolve this problem. Please refer to the
> > following for two kinds of patch.
> > Well, according to other code structures of hugeshmget0*.c, solution 1
> > is preferred. But for get_no_of_hugepages
> > will call popen(), so I think the second solution is the right one.
> > Will you please choose the right one to apply to
> > ltp-intermediate-20100119 package?
> > Looking forward to your confirmation!
> > 
> > Thanks and Best Regards,
> > shenghui
> > 
> > Solution 1===============================================================
> > 
> > diff -Nur
> > ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> >  ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> > ---
> > ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> >  2010-01-21 07:51:55.926035076 +0800
> > +++
> > ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> > 2010-01-21 08:14:05.470032624 +0800
> > @@ -78,14 +78,14 @@
> > tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> > }
> > 
> > -    setup();            /* global setup */
> > -
> > /* The following loop checks looping state if -i option given */
> > if ( get_no_of_hugepages() <= 0 || hugepages_size() <= 0 )
> > tst_brkm(TBROK, cleanup, "Test cannot be continued owning to
> > sufficient availability of Hugepages on the system");
> > else
> > -              huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
> > hugepages_size() * 1024) / 2 ;
> > -
> > +              huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
> > hugepages_size() * 1024) / 2 ;
> > +
> > +    setup();            /* global setup */
> > +
> > for (lc = 0; TEST_LOOPING(lc); lc++) {
> > /* reset Tst_count in case we are looping */
> > Tst_count = 0;
> > 
> > 
> > Solution
> > 2=========================================================================================
> >                 
> > diff -Nur
> > ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> >  ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> > ---
> > ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> >  2010-01-21 07:51:55.926035076 +0800
> > +++
> > ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
> > 2010-01-21 08:16:46.122032889 +0800
> > @@ -160,7 +160,7 @@
> > setup(void)
> > {
> > /* capture signals */
> > -    tst_sig(NOFORK, DEF_HANDLER, cleanup);
> > +    tst_sig(FORK, DEF_HANDLER, cleanup);
> > 
> > /* Pause if that option was specified */
> > TEST_PAUSE;
> > 
> > 
> > 
> > ------------------------------
> > 
> > ------------------------------------------------------------------------------
> > Throughout its 18-year history, RSA Conference consistently attracts the
> > world's best and brightest in the field, creating opportunities for Conference
> > attendees to learn about information security's most important issues through
> > interactions with peers, luminaries and emerging and established \
> > companies.http://p.sf.net/sfu/rsaconf-dev2dev 
> > ------------------------------
> > 
> > ______________________________
> > _________________
> > Ltp-list mailing \
> > listLtp-list@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/ltp-list
> >  
> > 
> > 
> > 
> > 
> 
> 
> --
> 
> 
> Thanks and Best Regards,
> shenghui
> 



-- 


Thanks and Best Regards,
shenghui


[Attachment #5 (text/html)]

Oh, I got it. There is some confusion.<br><br>1) In hugeshmget01.c, setup() will call \
<br>          tst_sig(NOFORK, DEF_HANDLER, cleanup);<br>2)  In include/test.h:<br>    \
/* defines for unexpected signal setup routine (set_usig.c) */<br>  #define FORK    1 \
/* SIGCLD is to be ignored */<br>                #define NOFORK  0               /* \
SIGCLD is to be caught */<br>     so here, hugeshmget01 want to catch SIGCLD.<br>3) \
                In lib/tst_gig.c:<br>
                ...<br>                case SIGCLD:<br>                        if \
(fork_flag == FORK || STD_COPIES &gt; 1)<br>                                \
continue;<br><br>                default:<br>                        if \
(tst_setup_signal(sig, handler) == SIG_ERR)<br>  tst_resm(TWARN | TERRNO,<br>         \
&quot;signal() failed for signal %d&quot;, sig);<br>                        \
break;<br>                ...<br><br>Here, if you donot use &quot;-c Xnumber&quot;, \
the SIGCLD handler will be def_handler, which will rise <br>  &quot;Unexpected signal \
%d received&quot; <br>when received signal SIGCLD<br>But if you use &quot;-c \
Xnumber&quot;, STD_COPIES &gt; 1 will be true, so the handler to SIGCLD is default, \
&quot;ignore&quot;.<br> <br><br>Confusion comes out:<br>           1. tst_sig(NOFORK, \
DEF_HANDLER, cleanup);       /* SIGCLD is to be caught */<br>           2. -c Xnumber \
will lead to SIGCLD ignored<br>Although the results are normal, but the code itself \
can lead to confusion. <br> So I suggest use the following patch:<br><br>--- \
hugeshmget01.c    2009-11-20 00:05:21.000000000 +0800<br>+++ hugeshmget01_1.c    \
2010-01-21 08:41:56.350057513 +0800<br>@@ -160,7 +160,7 @@<br> setup(void)<br> {<br>  \
                /* capture signals */<br>
-    tst_sig(NOFORK, DEF_HANDLER, cleanup);<br>+    tst_sig(FORK, DEF_HANDLER, \
cleanup);<br> <br>     /* Pause if that option was specified */<br>     \
TEST_PAUSE;<br><br><br><br><br><br><div class="gmail_quote">2010/1/21 Crossover \
Lonely <span dir="ltr">&lt;<a \
href="mailto:crosslonelyover@gmail.com">crosslonelyover@gmail.com</a>&gt;</span><br> \
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); \
margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>     I have tried &quot;gdb \
./hugeshmget01 -c 2&quot; and &quot;set follow-fork-mode child&quot;.<br> Then I \
traced into the child thread, and got<br>           &quot;hugeshmget01    1  TBROK  : \
Unexpected signal 17 received.&quot;<div><div></div><div class="h5"><br> <br><br><div \
class="gmail_quote">2010/1/21 liubo <span dir="ltr">&lt;<a \
href="mailto:liubo2009@cn.fujitsu.com" \
target="_blank">liubo2009@cn.fujitsu.com</a>&gt;</span><br><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;">




  

<div bgcolor="#ffffff" text="#000000">
Hi,<br>
<br>
    The hugeshmget01 case is designed for testing standard SYSV shared <br>
memory system calls &quot;shmget&quot;, and it do need a few concurrent copies <br>
in order to fulfill a multi-process memory-allocated environment.<br>
     <br>
    IMO, &quot;-c Xnumber&quot; is needed.<br>
<br>
Thanks,<br>
Liu Bo<div><div></div><div><br>
<pre><a name="1264f83ee1f8583e_1264f0609f38cffc_L14"></a></pre>
<br>
<br>
On 01/21/2010 10:14 AM, Crossover Lonely wrote:
</div></div><blockquote type="cite"><div><div></div><div>
  <pre>It works!
But isn&#39;t weird? Why just use ./hugeshmget won&#39;t work?
I traced it, and found it calls tsg_sig() in setup():
        tst_sig(NOFORK, DEF_HANDLER, cleanup);
and in tsg_sig():
        ...
               case SIGCLD:
            if (fork_flag == FORK || STD_COPIES &gt; 1)
                continue;

        default:
            if (tst_setup_signal(sig, handler) == SIG_ERR)
                tst_resm(TWARN | TERRNO,
                    &quot;signal() failed for signal %d&quot;, sig);
            break;
        ...

so here  hugeshmget set its action to SIGCLD to handler - here is
def_handler(), which can
rise &quot;Unexpected signal %d received.&quot; message when recived SIGCLD.
static void def_handler(int sig)
{
    /*
     * Break remaining test cases, do any cleanup, then exit
     */
    tst_brkm(TBROK, 0, &quot;Unexpected signal %d received.&quot;, sig);

    /* now cleanup and exit */
    if (T_cleanup)
        (*T_cleanup) ();

    tst_exit();
}

So I think it&#39;s better to correct it!

Thanks and Best Regards,
shenghui

2010/1/21 liubo <a href="mailto:liubo2009@cn.fujitsu.com" \
target="_blank">&lt;liubo2009@cn.fujitsu.com&gt;</a>

  </pre>
  </div></div><blockquote type="cite">
    <pre><div><div></div><div> Hi,

    In my box, I can add -c Xnumber to avoid the unexpect signal,
for example, ./hugeshmget -c 10. Maybe you can try this as well.

Thanks,
Liu Bo


On 01/21/2010 08:50 AM, Crossover Lonely wrote:

For your convenience, I just made to patches against the signle file, not
the whole directory.

solution 1=======================
--- hugeshmget01.c    2009-11-20 00:05:21.000000000 +0800
+++ hugeshmget01_2.c    2010-01-21 08:43:11.790533086 +0800
@@ -78,14 +78,14 @@
         tst_brkm(TBROK, cleanup, &quot;OPTION PARSING ERROR - %s&quot;, msg);
     }

-    setup();            /* global setup */
-
     /* The following loop checks looping state if -i option given */
         if ( get_no_of_hugepages() &lt;= 0 || hugepages_size() &lt;= 0 )
              tst_brkm(TBROK, cleanup, &quot;Test cannot be continued owning to
sufficient availability of Hugepages on the system&quot;);
         else
               huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;

+    setup();            /* global setup */
+
         for (lc = 0; TEST_LOOPING(lc); lc++) {
         /* reset Tst_count in case we are looping */
         Tst_count = 0;


solution 2=============================</div></div>=
--- hugeshmget01.c    2009-11-20 00:05:21.000000000 +0800
+++ hugeshmget01_1.c    2010-01-21 08:41:56.350057513 +0800
@@ -160,7 +160,7 @@
 setup(void)
 {
     /* capture signals */
-    tst_sig(NOFORK, DEF_HANDLER, cleanup);
+    tst_sig(FORK, DEF_HANDLER, cleanup);

     /* Pause if that option was specified */
     TEST_PAUSE;


2010/1/21 Crossover Lonely <a href="mailto:crosslonelyover@gmail.com" \
target="_blank">&lt;crosslonelyover@gmail.com&gt;</a> <a \
href="mailto:crosslonelyover@gmail.com" \
target="_blank">&lt;crosslonelyover@gmail.com&gt;</a><div>

<div></div><div>

   Hi all,

     When the hugeshmget01 runs, it gets unexpected signal SIGCHLD/SIGCLD,
and thus stops immediately.
     I found two ways to resolve this problem. Please refer to the
following for two kinds of patch.
     Well, according to other code structures of hugeshmget0*.c, solution 1
is preferred. But for get_no_of_hugepages
will call popen(), so I think the second solution is the right one.
     Will you please choose the right one to apply to
ltp-intermediate-20100119 package?
     Looking forward to your confirmation!

Thanks and Best Regards,
shenghui

Solution 1===============================================================

diff -Nur
ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
 ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
---
ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
 2010-01-21 07:51:55.926035076 +0800
+++
ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
2010-01-21 08:14:05.470032624 +0800
@@ -78,14 +78,14 @@
         tst_brkm(TBROK, cleanup, &quot;OPTION PARSING ERROR - %s&quot;, msg);
     }

-    setup();            /* global setup */
-
     /* The following loop checks looping state if -i option given */
         if ( get_no_of_hugepages() &lt;= 0 || hugepages_size() &lt;= 0 )
              tst_brkm(TBROK, cleanup, &quot;Test cannot be continued owning to
sufficient availability of Hugepages on the system&quot;);
         else
-              huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;
-
+              huge_pages_shm_to_be_allocated = ( get_no_of_hugepages() *
hugepages_size() * 1024) / 2 ;
+
+    setup();            /* global setup */
+
         for (lc = 0; TEST_LOOPING(lc); lc++) {
         /* reset Tst_count in case we are looping */
         Tst_count = 0;


Solution
2=========================================================================================
                
diff -Nur
ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
 ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
---
ltp-intermediate-20100119-origin/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
 2010-01-21 07:51:55.926035076 +0800
+++
ltp-intermediate-20100119/testcases/kernel/mem/hugetlb/hugeshmget/hugeshmget01.c
2010-01-21 08:16:46.122032889 +0800
@@ -160,7 +160,7 @@
 setup(void)
 {
     /* capture signals */
-    tst_sig(NOFORK, DEF_HANDLER, cleanup);
+    tst_sig(FORK, DEF_HANDLER, cleanup);

     /* Pause if that option was specified */
     TEST_PAUSE;



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

------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world&#39;s best and brightest in the field, creating opportunities for Conference
attendees to learn about information security&#39;s most important issues through
interactions with peers, luminaries and emerging and established companies.<a \
href="http://p.sf.net/sfu/rsaconf-dev2dev" \
target="_blank">http://p.sf.net/sfu/rsaconf-dev2dev</a>

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

______________________________</div></div>_________________
Ltp-list mailing <a href="mailto:listLtp-list@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/ltp-list" \
target="_blank">listLtp-list@lists.sourceforge.nethttps://lists.sourceforge.net/lists/listinfo/ltp-list</a>




    </pre>
  </blockquote>
  <pre>  </pre>
</blockquote>
<br>
</div>

</blockquote></div><br><br clear="all"><br></div></div>-- <br><div><div></div><div \
class="h5"><br><br>Thanks and Best Regards,<br>shenghui<br> \
</div></div></blockquote></div><br><br clear="all"><br>-- <br><br><br>Thanks and Best \
Regards,<br>shenghui<br>



------------------------------------------------------------------------------
Throughout its 18-year history, RSA Conference consistently attracts the
world's best and brightest in the field, creating opportunities for Conference
attendees to learn about information security's most important issues through
interactions with peers, luminaries and emerging and established companies.
http://p.sf.net/sfu/rsaconf-dev2dev

_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic