On 01/26/2015 04:11 PM, Cyril Hrubis wrote:
>> @@ -100,6 +153,21 @@ void tst_module_load(void (cleanup_fn)(void),
>>
>>   void tst_module_unload(void (cleanup_fn)(void), const char *mod_name)
>>   {
>> +    int i;
>> +    int loaded;
>> +
>>      const char *const argv[] = { "rmmod", mod_name, NULL };
>> -    tst_run_cmd(cleanup_fn, argv, NULL, NULL, 0);
>> +
>> +    loaded = 1;
>> +    for (i = 0; i < 50; i++) {
>> +            tst_run_cmd(NULL, argv, "/dev/null", "/dev/null", 1);
>
> Can we trust the return value from the rrmod? Because if it's correctly
> propagated we can simplify this loop to just checking the return value
> here.

Hmm. I think we can, and the previous (current) version of tst_run_cmd 
relied on that.

So tst_module_unload() will be like:

void tst_module_unload(void (cleanup_fn)(void), const char *mod_name)
{
        int i;
         int rc;

         const char *const argv[] = { "rmmod", mod_name, NULL };

         rc = 1;
         for (i = 0; i < 50; i++) {
                 rc = tst_run_cmd(NULL, argv, "/dev/null", "/dev/null", 1);
                 if (!rc)
                         break;

                usleep(20000);
         }

         if (rc) {
                 tst_brkm(TBROK, cleanup_fn,
                          "could not unload %s module", mod_name);
         }
}

and there is no need for tst_module_is_loaded() function.


>
>> +            loaded = tst_module_is_loaded(cleanup_fn, mod_name);
>> +            if (!loaded)
>> +                    break;
>
> What about adding usleep(20000) here? Because otherwise this is bussy
> loop that does not give much chances to other processes to run (on a
> single CPU machine).

For sure. It was initially planned to have a usleep() here, but I 
somehow overlooked it.


I'll send a new version which modifies only tst_module_unload.

Thanks.

>
>> +    }
>> +
>> +    if (loaded)
>> +            tst_brkm(TBROK, cleanup_fn,
>> +                     "could not unload %s module", mod_name);
>>   }
>

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

Reply via email to