~ubuntu-branches/ubuntu/wily/spl-linux/wily-proposed

« back to all changes in this revision

Viewing changes to module/splat/splat-kmem.c

  • Committer: Package Import Robot
  • Author(s): Liang Guo
  • Date: 2014-07-31 15:16:53 UTC
  • Revision ID: package-import@ubuntu.com-20140731151653-tgao12alohj26jcs
Tags: upstream-0.6.3+git20140731
ImportĀ upstreamĀ versionĀ 0.6.3+git20140731

Show diffs side-by-side

added added

removed removed

Lines of Context:
244
244
#define SPLAT_KMEM_TEST_MAGIC           0x004488CCUL
245
245
#define SPLAT_KMEM_CACHE_NAME           "kmem_test"
246
246
#define SPLAT_KMEM_OBJ_COUNT            1024
247
 
#define SPLAT_KMEM_OBJ_RECLAIM          1000 /* objects */
 
247
#define SPLAT_KMEM_OBJ_RECLAIM          32 /* objects */
248
248
#define SPLAT_KMEM_THREADS              32
249
249
 
250
250
#define KCP_FLAG_READY                  0x01
394
394
{
395
395
        int j;
396
396
 
397
 
        splat_vprint(file, name,
398
 
                     "%s cache objects %d, slabs %u/%u objs %u/%u mags ",
399
 
                     kcp->kcp_cache->skc_name, kcp->kcp_count,
 
397
        splat_vprint(file, name, "%s cache objects %d",
 
398
             kcp->kcp_cache->skc_name, kcp->kcp_count);
 
399
 
 
400
        if (kcp->kcp_cache->skc_flags & (KMC_KMEM | KMC_VMEM)) {
 
401
                splat_vprint(file, name, ", slabs %u/%u objs %u/%u",
400
402
                     (unsigned)kcp->kcp_cache->skc_slab_alloc,
401
403
                     (unsigned)kcp->kcp_cache->skc_slab_total,
402
404
                     (unsigned)kcp->kcp_cache->skc_obj_alloc,
403
405
                     (unsigned)kcp->kcp_cache->skc_obj_total);
404
406
 
405
 
        for_each_online_cpu(j)
406
 
                splat_print(file, "%u/%u ",
407
 
                             kcp->kcp_cache->skc_mag[j]->skm_avail,
408
 
                             kcp->kcp_cache->skc_mag[j]->skm_size);
 
407
                if (!(kcp->kcp_cache->skc_flags & KMC_NOMAGAZINE)) {
 
408
                        splat_vprint(file, name, "%s", "mags");
 
409
 
 
410
                        for_each_online_cpu(j)
 
411
                                splat_print(file, "%u/%u ",
 
412
                                     kcp->kcp_cache->skc_mag[j]->skm_avail,
 
413
                                     kcp->kcp_cache->skc_mag[j]->skm_size);
 
414
                }
 
415
        }
409
416
 
410
417
        splat_print(file, "%s\n", "");
411
418
}
682
689
                goto out_kcp;
683
690
        }
684
691
 
685
 
        start = current_kernel_time();
 
692
        getnstimeofday(&start);
686
693
 
687
694
        for (i = 0; i < SPLAT_KMEM_THREADS; i++) {
688
695
                thr = thread_create(NULL, 0,
707
714
        /* Sleep until all thread have finished */
708
715
        wait_event(kcp->kcp_ctl_waitq, splat_kmem_cache_test_threads(kcp, 0));
709
716
 
710
 
        stop = current_kernel_time();
 
717
        getnstimeofday(&stop);
711
718
        delta = timespec_sub(stop, start);
712
719
 
713
720
        splat_vprint(file, name,
895
902
                goto out_kct;
896
903
        }
897
904
 
898
 
        for (i = 0; i < 60; i++) {
 
905
        /* Force reclaim every 1/10 a second for 60 seconds. */
 
906
        for (i = 0; i < 600; i++) {
899
907
                kmem_cache_reap_now(kcp->kcp_cache);
900
908
                splat_kmem_cache_test_debug(file, SPLAT_KMEM_TEST8_NAME, kcp);
901
909
 
902
 
                if (kcp->kcp_cache->skc_obj_total == 0)
 
910
                if (kcp->kcp_count == 0)
903
911
                        break;
904
912
 
905
913
                set_current_state(TASK_INTERRUPTIBLE);
906
 
                schedule_timeout(HZ);
 
914
                schedule_timeout(HZ / 10);
907
915
        }
908
916
 
909
 
        if (kcp->kcp_cache->skc_obj_total == 0) {
 
917
        if (kcp->kcp_count == 0) {
910
918
                splat_vprint(file, SPLAT_KMEM_TEST8_NAME,
911
919
                        "Successfully created %d objects "
912
920
                        "in cache %s and reclaimed them\n",
914
922
        } else {
915
923
                splat_vprint(file, SPLAT_KMEM_TEST8_NAME,
916
924
                        "Failed to reclaim %u/%d objects from cache %s\n",
917
 
                        (unsigned)kcp->kcp_cache->skc_obj_total,
 
925
                        (unsigned)kcp->kcp_count,
918
926
                        SPLAT_KMEM_OBJ_COUNT, SPLAT_KMEM_CACHE_NAME);
919
927
                rc = -ENOMEM;
920
928
        }
994
1002
        for (i = 0; i < 60; i++) {
995
1003
                splat_kmem_cache_test_debug(file, SPLAT_KMEM_TEST9_NAME, kcp);
996
1004
 
997
 
                if (kcp->kcp_cache->skc_obj_total == 0)
 
1005
                if (kcp->kcp_count == 0)
998
1006
                        break;
999
1007
 
1000
1008
                set_current_state(TASK_INTERRUPTIBLE);
1001
1009
                schedule_timeout(HZ);
1002
1010
        }
1003
1011
 
1004
 
        if (kcp->kcp_cache->skc_obj_total == 0) {
 
1012
        if (kcp->kcp_count == 0) {
1005
1013
                splat_vprint(file, SPLAT_KMEM_TEST9_NAME,
1006
1014
                        "Successfully created %d objects "
1007
1015
                        "in cache %s and reclaimed them\n",
1009
1017
        } else {
1010
1018
                splat_vprint(file, SPLAT_KMEM_TEST9_NAME,
1011
1019
                        "Failed to reclaim %u/%d objects from cache %s\n",
1012
 
                        (unsigned)kcp->kcp_cache->skc_obj_total, count,
 
1020
                        (unsigned)kcp->kcp_count, count,
1013
1021
                        SPLAT_KMEM_CACHE_NAME);
1014
1022
                rc = -ENOMEM;
1015
1023
        }
1203
1211
        kmem_cache_thread_t *kct;
1204
1212
        dummy_page_t *dp;
1205
1213
        struct list_head list;
1206
 
        struct timespec start, delta = { 0, 0 };
 
1214
        struct timespec start, stop, delta = { 0, 0 };
1207
1215
        int size, count, slabs, fails = 0;
1208
1216
        int i, rc = 0, max_time = 10;
1209
1217
 
1250
1258
        i = 0;
1251
1259
        slabs = kcp->kcp_cache->skc_slab_total;
1252
1260
        INIT_LIST_HEAD(&list);
1253
 
        start = current_kernel_time();
 
1261
        getnstimeofday(&start);
1254
1262
 
1255
1263
        /* Apply memory pressure */
1256
1264
        while (kcp->kcp_cache->skc_slab_total > (slabs >> 2)) {
1259
1267
                        splat_kmem_cache_test_debug(
1260
1268
                            file, SPLAT_KMEM_TEST13_NAME, kcp);
1261
1269
 
1262
 
                delta = timespec_sub(current_kernel_time(), start);
 
1270
                getnstimeofday(&stop);
 
1271
                delta = timespec_sub(stop, start);
1263
1272
                if (delta.tv_sec >= max_time) {
1264
1273
                        splat_vprint(file, SPLAT_KMEM_TEST13_NAME,
1265
1274
                                     "Failed to reclaim 3/4 of cache in %ds, "
1270
1279
                        break;
1271
1280
                }
1272
1281
 
1273
 
                dp = (dummy_page_t *)__get_free_page(GFP_KERNEL | __GFP_NORETRY);
 
1282
                dp = (dummy_page_t *)__get_free_page(GFP_KERNEL);
1274
1283
                if (!dp) {
1275
1284
                        fails++;
1276
1285
                        splat_vprint(file, SPLAT_KMEM_TEST13_NAME,