函数源码

Linux Kernel

v5.5.9

Brick Technologies Co., Ltd

Source File:mm\slab.c Create Date:2022-07-27 17:18:39
首页 Copyright©Brick

2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
static void cache_init_objs_debug(struct kmem_cache *cachep, struct page *page)
{
#if DEBUG
    int i;
 
    for (i = 0; i < cachep->num; i++) {
        void *objp = index_to_obj(cachep, page, i);
 
        if (cachep->flags & SLAB_STORE_USER)
            *dbg_userword(cachep, objp) = NULL;
 
        if (cachep->flags & SLAB_RED_ZONE) {
            *dbg_redzone1(cachep, objp) = RED_INACTIVE;
            *dbg_redzone2(cachep, objp) = RED_INACTIVE;
        }
        /*
         * Constructors are not allowed to allocate memory from the same
         * cache which they are a constructor for.  Otherwise, deadlock.
         * They must also be threaded.
         */
        if (cachep->ctor && !(cachep->flags & SLAB_POISON)) {
            kasan_unpoison_object_data(cachep,
                           objp + obj_offset(cachep));
            cachep->ctor(objp + obj_offset(cachep));
            kasan_poison_object_data(
                cachep, objp + obj_offset(cachep));
        }
 
        if (cachep->flags & SLAB_RED_ZONE) {
            if (*dbg_redzone2(cachep, objp) != RED_INACTIVE)
                slab_error(cachep, "constructor overwrote the end of an object");
            if (*dbg_redzone1(cachep, objp) != RED_INACTIVE)
                slab_error(cachep, "constructor overwrote the start of an object");
        }
        /* need to poison the objs? */
        if (cachep->flags & SLAB_POISON) {
            poison_obj(cachep, objp, POISON_FREE);
            slab_kernel_map(cachep, objp, 0);
        }
    }
#endif
}