Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright 2014, Michael Ellerman, IBM Corp.
0004  */
0005 
0006 #include <stdio.h>
0007 #include <stdlib.h>
0008 
0009 #include "event.h"
0010 #include "utils.h"
0011 
0012 #define MALLOC_SIZE     (0x10000 * 10)  /* Ought to be enough .. */
0013 
0014 /*
0015  * Tests that the L3 bank handling is correct. We fixed it in commit e9aaac1.
0016  */
0017 static int l3_bank_test(void)
0018 {
0019     struct event event;
0020     char *p;
0021     int i;
0022 
0023     // The L3 bank logic is only used on Power8 or later
0024     SKIP_IF(!have_hwcap2(PPC_FEATURE2_ARCH_2_07));
0025 
0026     p = malloc(MALLOC_SIZE);
0027     FAIL_IF(!p);
0028 
0029     event_init(&event, 0x84918F);
0030 
0031     FAIL_IF(event_open(&event));
0032 
0033     for (i = 0; i < MALLOC_SIZE; i += 0x10000)
0034         p[i] = i;
0035 
0036     event_read(&event);
0037     event_report(&event);
0038 
0039     FAIL_IF(event.result.running == 0);
0040     FAIL_IF(event.result.enabled == 0);
0041 
0042     event_close(&event);
0043     free(p);
0044 
0045     return 0;
0046 }
0047 
0048 int main(void)
0049 {
0050     return test_harness(l3_bank_test, "l3_bank_test");
0051 }