2010-12-02 08:36:30     sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Document created by Aaronwu Employee on Aug 23, 2013
Version 1Show Document
  • View in full screen mode

2010-12-02 08:36:30     sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Fisher Ho (TAIWAN)

Message: 96410   

 

Dear Sirs,

 

 

 

        I used

 

 

 

/* bind process to processor 0 */

    cpu_set_t cmask;

       unsigned long len = sizeof(cmask);

    __CPU_ZERO(&cmask);   /* initialize cmask */

    __CPU_SET(0, &cmask); /* bind to one */

 

        if (sched_setaffinity(0, len, &cmask) <0) {

        perror("sched_setaffinity");

        }

 

 

 

to bound a process to a specific core in SMP-like mode at BF561 EZkite

 

 

 

and I allocated data to sram

 

int *a;

 

  a = (int*) sram_alloc (sizeof(src), L1_DATA_A_SRAM);

 

        This is OK, but

 

 

 

when performing

 

sram_free(a);

 

 

 

it didn't work and having no error message, it returns 0;

 

 

 

But this happened only to bounding to core 1, 

 

it didn't happen in bounding to core2,

 

      __CPU_SET(1, &cmask); /* bind to core two */

 

 

 

Is it a bug?

 

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

 

Thank you for your concren

TranslateQuoteReplyEditDelete

 

 

2010-12-02 08:51:42     Re: sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Mike Frysinger (UNITED STATES)

Message: 96411   

 

the sram code should handle per-cpu alloc/free just fine.  obviously it's up to you to make sure the process sets its affinity before calling alloc/free and doesnt move between processors in the mean time.

 

what exactly do you mean by "it didn't work" ?  how are you determining whether the free worked ?

 

please post a simple application we can compile & execute ourselves.  code snippets are often not useful for reproducing problems.

QuoteReplyEditDelete

 

 

2010-12-02 10:12:38     Re: sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Fisher Ho (TAIWAN)

Message: 96414   

 

#ifndef _GNU_SOURCE

#define _GNU_SOURCE

#endif

 

 

#include <stdio.h>

#include <bfin_sram.h>

 

 

 

int main ()

{

    int *sram_ptr, i;

 

    /* bind process to processor 0 */

    cpu_set_t cmask;

       unsigned long len = sizeof(cmask);

    __CPU_ZERO(&cmask);   /* initialize cmask */

    __CPU_SET(0, &cmask); /* bind to one */

  

    if (sched_setaffinity(0, len, &cmask) <0) {

        perror("sched_setaffinity");

    }

  

    printf("Wait ");printf("for ");printf("change ");printf("to core1\n");

 

    printf("Now we are in core 1\n");

  

    /* allocate sram in Core 1 and free */

    for(i=0;i<10;i++)

    {

        sram_ptr = (int*) sram_alloc (1, L1_DATA_A_SRAM);

        if(sram_free(sram_ptr) < 0)

            printf("sram_free error");

        printf("After sram_ptr is cleared; sram_ptr:%x: \n", (int)sram_ptr);

    }

  

  

     

    __CPU_ZERO(&cmask);   /* initialize cmask */

    __CPU_SET(1, &cmask); /* bind to two */

  

    if (sched_setaffinity(0, len, &cmask) <0) {

        perror("sched_setaffinity");

    }

  

    printf("Wait ");printf("for ");printf("change ");printf("to core2\n");

 

    printf("Now we are in core 2\n");

  

    /* allocate sram in Core 2 and free */

    for(i=0;i<10;i++)

    {

        sram_ptr = (int*) sram_alloc (1, L1_DATA_A_SRAM);

        if(sram_free(sram_ptr) < 0)

            printf("sram_free error");

        printf("After sram_ptr is cleared; sram_ptr:%x: \n", (int)sram_ptr);

    }

    return  0;

}

 

 

 

and the ouput is

 

root:/> ./a.out

Wait for change to core1

Now we are in core 1

After sram_ptr is cleared; sram_ptr:ff800000:

After sram_ptr is cleared; sram_ptr:ff800004:

After sram_ptr is cleared; sram_ptr:ff800008:

After sram_ptr is cleared; sram_ptr:ff80000c:

After sram_ptr is cleared; sram_ptr:ff800010:

After sram_ptr is cleared; sram_ptr:ff800014:

After sram_ptr is cleared; sram_ptr:ff800018:

After sram_ptr is cleared; sram_ptr:ff80001c:

After sram_ptr is cleared; sram_ptr:ff800020:

After sram_ptr is cleared; sram_ptr:ff800024:

Wait for change to core2

Now we are in core 2

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

After sram_ptr is cleared; sram_ptr:ff400000:

root:/>

TranslateQuoteReplyEditDelete

 

 

2010-12-06 16:04:16     Re: sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Mike Frysinger (UNITED STATES)

Message: 96512   

 

thanks, i'm able to reproduce the issue with your simple test case.  i'll commit the fix to the svn branch/trunk shortly.

QuoteReplyEditDelete

 

 

2010-12-06 16:08:35     Re: sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Mike Frysinger (UNITED STATES)

Message: 96513   

 

actually, it seems to already be fixed in trunk.  it was introduced during some code shuffling and is specific to 2010R1.

QuoteReplyEditDelete

 

 

2010-12-09 10:07:37     Re: sram_free() seems to fail when bounding a process to a specific core in SMP bf561

Fisher Ho (TAIWAN)

Message: 96591   

 

Roger that, Thank you for your reply. : )

Attachments

    Outcomes