Question about setting heap.alloc_class faild

19 views
Skip to first unread message

onceltl

unread,
Jul 31, 2020, 7:16:33 AM7/31/20
to pmem
Hi,experts
    I try to use the following code to set alloc_class
   why set res is always equal to -1? What is wrong with my code? Need help!  
Thanks

            int sds_write_value = 0;
            pmemobj_ctl_set(NULL, "sds.at_create", &sds_write_value);
            if ((pop = pmemobj_create(poolpath.c_str(), POBJ_LAYOUT_NAME("test"),
    poolsize,0666)) == NULL) 
            {
                printf("failed to create pool. path is : %s\n",poolpath.c_str());
                return ;
            }

            pobj_alloc_class_desc readclass;
            pobj_alloc_class_desc AllocClass;
            AllocClass.unit_size = 512;
            AllocClass.alignment = 64;
            AllocClass.units_per_block = 0;
            AllocClass.class_id = 128;
            AllocClass.header_type = POBJ_HEADER_COMPACT;
        
            int  res = pmemobj_ctl_set(pop, "heap.alloc_class.128.desc", &AllocClass);
            printf("set res: %d\n",res);
            res = pmemobj_ctl_get(pop, "heap.alloc_class.128.desc", &readclass);
            printf("get res: %d\n",res);

ppbb...@gmail.com

unread,
Jul 31, 2020, 7:39:09 AM7/31/20
to pmem
Units per block must be at least 1. It will get rounded-up to the nearest chunksize anyway, so you don't have to be precise.

onceltl

unread,
Jul 31, 2020, 8:19:37 AM7/31/20
to pmem
solved!By the way, I'm curious why there is no POBJ_ macro relative to pmemobj_xalloc().

在 2020年7月31日星期五 UTC+8下午7:39:09,ppbb...@gmail.com写道:

ppbb...@gmail.com

unread,
Jul 31, 2020, 8:42:16 AM7/31/20
to pmem
Lack of x-variant macros for the atomic API looks like an omission on our part. But TBH we expect that most users that need flags won't use macros anyway.
It's very little effort to add those macros - we will do that in the next release.
Reply all
Reply to author
Forward
0 new messages