@@ -1383,7 +1383,8 @@ static void aux_output_end(struct perf_output_handle *handle)
1383
1383
te = aux_sdb_trailer (aux , aux -> alert_mark );
1384
1384
te -> flags &= ~SDB_TE_ALERT_REQ_MASK ;
1385
1385
1386
- debug_sprintf_event (sfdbg , 6 , "%s: collect %#lx SDBs\n" , __func__ , i );
1386
+ debug_sprintf_event (sfdbg , 6 , "%s: SDBs %ld range %ld head %ld\n" ,
1387
+ __func__ , i , range_scan , aux -> head );
1387
1388
}
1388
1389
1389
1390
/*
@@ -1416,13 +1417,17 @@ static int aux_output_begin(struct perf_output_handle *handle,
1416
1417
* SDBs between aux->head and aux->empty_mark are already ready
1417
1418
* for new data. range_scan is num of SDBs not within them.
1418
1419
*/
1420
+ debug_sprintf_event (sfdbg , 6 ,
1421
+ "%s: range %ld head %ld alert %ld empty %ld\n" ,
1422
+ __func__ , range , aux -> head , aux -> alert_mark ,
1423
+ aux -> empty_mark );
1419
1424
if (range > AUX_SDB_NUM_EMPTY (aux )) {
1420
1425
range_scan = range - AUX_SDB_NUM_EMPTY (aux );
1421
1426
idx = aux -> empty_mark + 1 ;
1422
1427
for (i = 0 ; i < range_scan ; i ++ , idx ++ ) {
1423
1428
te = aux_sdb_trailer (aux , idx );
1424
- te -> flags = te -> flags & ~ SDB_TE_BUFFER_FULL_MASK ;
1425
- te -> flags = te -> flags & ~ SDB_TE_ALERT_REQ_MASK ;
1429
+ te -> flags &= ~( SDB_TE_BUFFER_FULL_MASK |
1430
+ SDB_TE_ALERT_REQ_MASK ) ;
1426
1431
te -> overflow = 0 ;
1427
1432
}
1428
1433
/* Save the position of empty SDBs */
@@ -1441,15 +1446,11 @@ static int aux_output_begin(struct perf_output_handle *handle,
1441
1446
cpuhw -> lsctl .tear = base + offset * sizeof (unsigned long );
1442
1447
cpuhw -> lsctl .dear = aux -> sdb_index [head ];
1443
1448
1444
- debug_sprintf_event (sfdbg , 6 , "%s: "
1445
- "head->alert_mark->empty_mark (num_alert, range)"
1446
- "[%#lx -> %#lx -> %#lx] (%#lx, %#lx) "
1447
- "tear index %#lx, tear %#lx dear %#lx\n" , __func__ ,
1449
+ debug_sprintf_event (sfdbg , 6 , "%s: head %ld alert %ld empty %ld "
1450
+ "index %ld tear %#lx dear %#lx\n" , __func__ ,
1448
1451
aux -> head , aux -> alert_mark , aux -> empty_mark ,
1449
- AUX_SDB_NUM_ALERT (aux ), range ,
1450
1452
head / CPUM_SF_SDB_PER_TABLE ,
1451
- cpuhw -> lsctl .tear ,
1452
- cpuhw -> lsctl .dear );
1453
+ cpuhw -> lsctl .tear , cpuhw -> lsctl .dear );
1453
1454
1454
1455
return 0 ;
1455
1456
}
@@ -1469,8 +1470,7 @@ static bool aux_set_alert(struct aux_buffer *aux, unsigned long alert_index,
1469
1470
te = aux_sdb_trailer (aux , alert_index );
1470
1471
do {
1471
1472
orig_flags = te -> flags ;
1472
- orig_overflow = te -> overflow ;
1473
- * overflow = orig_overflow ;
1473
+ * overflow = orig_overflow = te -> overflow ;
1474
1474
if (orig_flags & SDB_TE_BUFFER_FULL_MASK ) {
1475
1475
/*
1476
1476
* SDB is already set by hardware.
@@ -1512,9 +1512,12 @@ static bool aux_reset_buffer(struct aux_buffer *aux, unsigned long range,
1512
1512
unsigned long long * overflow )
1513
1513
{
1514
1514
unsigned long long orig_overflow , orig_flags , new_flags ;
1515
- unsigned long i , range_scan , idx ;
1515
+ unsigned long i , range_scan , idx , idx_old ;
1516
1516
struct hws_trailer_entry * te ;
1517
1517
1518
+ debug_sprintf_event (sfdbg , 6 , "%s: range %ld head %ld alert %ld "
1519
+ "empty %ld\n" , __func__ , range , aux -> head ,
1520
+ aux -> alert_mark , aux -> empty_mark );
1518
1521
if (range <= AUX_SDB_NUM_EMPTY (aux ))
1519
1522
/*
1520
1523
* No need to scan. All SDBs in range are marked as empty.
@@ -1537,7 +1540,7 @@ static bool aux_reset_buffer(struct aux_buffer *aux, unsigned long range,
1537
1540
* indicator fall into this range, set it.
1538
1541
*/
1539
1542
range_scan = range - AUX_SDB_NUM_EMPTY (aux );
1540
- idx = aux -> empty_mark + 1 ;
1543
+ idx_old = idx = aux -> empty_mark + 1 ;
1541
1544
for (i = 0 ; i < range_scan ; i ++ , idx ++ ) {
1542
1545
te = aux_sdb_trailer (aux , idx );
1543
1546
do {
@@ -1557,6 +1560,9 @@ static bool aux_reset_buffer(struct aux_buffer *aux, unsigned long range,
1557
1560
/* Update empty_mark to new position */
1558
1561
aux -> empty_mark = aux -> head + range - 1 ;
1559
1562
1563
+ debug_sprintf_event (sfdbg , 6 , "%s: range_scan %ld idx %ld..%ld "
1564
+ "empty %ld\n" , __func__ , range_scan , idx_old ,
1565
+ idx - 1 , aux -> empty_mark );
1560
1566
return true;
1561
1567
}
1562
1568
@@ -1570,24 +1576,24 @@ static void hw_collect_aux(struct cpu_hw_sf *cpuhw)
1570
1576
unsigned long range = 0 , size ;
1571
1577
unsigned long long overflow = 0 ;
1572
1578
struct perf_output_handle * handle = & cpuhw -> handle ;
1573
- unsigned long num_sdb ;
1574
1579
1575
1580
aux = perf_get_aux (handle );
1576
1581
if (WARN_ON_ONCE (!aux ))
1577
1582
return ;
1578
1583
1579
1584
/* Inform user space new data arrived */
1580
1585
size = AUX_SDB_NUM_ALERT (aux ) << PAGE_SHIFT ;
1586
+ debug_sprintf_event (sfdbg , 6 , "%s: #alert %ld\n" , __func__ ,
1587
+ size >> PAGE_SHIFT );
1581
1588
perf_aux_output_end (handle , size );
1582
- num_sdb = aux -> sfb .num_sdb ;
1583
1589
1584
1590
while (!done ) {
1585
1591
/* Get an output handle */
1586
1592
aux = perf_aux_output_begin (handle , cpuhw -> event );
1587
1593
if (handle -> size == 0 ) {
1588
1594
pr_err ("The AUX buffer with %lu pages for the "
1589
1595
"diagnostic-sampling mode is full\n" ,
1590
- num_sdb );
1596
+ aux -> sfb . num_sdb );
1591
1597
debug_sprintf_event (sfdbg , 1 ,
1592
1598
"%s: AUX buffer used up\n" ,
1593
1599
__func__ );
@@ -1612,26 +1618,24 @@ static void hw_collect_aux(struct cpu_hw_sf *cpuhw)
1612
1618
size = range << PAGE_SHIFT ;
1613
1619
perf_aux_output_end (& cpuhw -> handle , size );
1614
1620
pr_err ("Sample data caused the AUX buffer with %lu "
1615
- "pages to overflow\n" , num_sdb );
1616
- debug_sprintf_event (sfdbg , 1 , "%s: head %#lx range %#lx "
1617
- "overflow %#llx \n" , __func__ ,
1621
+ "pages to overflow\n" , aux -> sfb . num_sdb );
1622
+ debug_sprintf_event (sfdbg , 1 , "%s: head %ld range %ld "
1623
+ "overflow %lld \n" , __func__ ,
1618
1624
aux -> head , range , overflow );
1619
1625
} else {
1620
1626
size = AUX_SDB_NUM_ALERT (aux ) << PAGE_SHIFT ;
1621
1627
perf_aux_output_end (& cpuhw -> handle , size );
1622
- debug_sprintf_event (sfdbg , 6 , "%s: head %#lx alert %#lx "
1628
+ debug_sprintf_event (sfdbg , 6 , "%s: head %ld alert %ld "
1623
1629
"already full, try another\n" ,
1624
1630
__func__ ,
1625
1631
aux -> head , aux -> alert_mark );
1626
1632
}
1627
1633
}
1628
1634
1629
1635
if (done )
1630
- debug_sprintf_event (sfdbg , 6 , "%s: aux_reset_buffer "
1631
- "[%#lx -> %#lx -> %#lx] (%#lx, %#lx)\n" ,
1632
- __func__ , aux -> head , aux -> alert_mark ,
1633
- aux -> empty_mark , AUX_SDB_NUM_ALERT (aux ),
1634
- range );
1636
+ debug_sprintf_event (sfdbg , 6 , "%s: head %ld alert %ld "
1637
+ "empty %ld\n" , __func__ , aux -> head ,
1638
+ aux -> alert_mark , aux -> empty_mark );
1635
1639
}
1636
1640
1637
1641
/*
@@ -1654,8 +1658,7 @@ static void aux_buffer_free(void *data)
1654
1658
kfree (aux -> sdb_index );
1655
1659
kfree (aux );
1656
1660
1657
- debug_sprintf_event (sfdbg , 4 , "%s: free "
1658
- "%lu SDBTs\n" , __func__ , num_sdbt );
1661
+ debug_sprintf_event (sfdbg , 4 , "%s: SDBTs %lu\n" , __func__ , num_sdbt );
1659
1662
}
1660
1663
1661
1664
static void aux_sdb_init (unsigned long sdb )
@@ -1707,13 +1710,13 @@ static void *aux_buffer_setup(struct perf_event *event, void **pages,
1707
1710
}
1708
1711
1709
1712
/* Allocate aux_buffer struct for the event */
1710
- aux = kmalloc (sizeof (struct aux_buffer ), GFP_KERNEL );
1713
+ aux = kzalloc (sizeof (struct aux_buffer ), GFP_KERNEL );
1711
1714
if (!aux )
1712
1715
goto no_aux ;
1713
1716
sfb = & aux -> sfb ;
1714
1717
1715
1718
/* Allocate sdbt_index for fast reference */
1716
- n_sdbt = (nr_pages + CPUM_SF_SDB_PER_TABLE - 1 ) / CPUM_SF_SDB_PER_TABLE ;
1719
+ n_sdbt = DIV_ROUND_UP (nr_pages , CPUM_SF_SDB_PER_TABLE ) ;
1717
1720
aux -> sdbt_index = kmalloc_array (n_sdbt , sizeof (void * ), GFP_KERNEL );
1718
1721
if (!aux -> sdbt_index )
1719
1722
goto no_sdbt_index ;
@@ -1763,8 +1766,8 @@ static void *aux_buffer_setup(struct perf_event *event, void **pages,
1763
1766
*/
1764
1767
aux -> empty_mark = sfb -> num_sdb - 1 ;
1765
1768
1766
- debug_sprintf_event (sfdbg , 4 , "%s: setup %lu SDBTs and %lu SDBs \n" ,
1767
- __func__ , sfb -> num_sdbt , sfb -> num_sdb );
1769
+ debug_sprintf_event (sfdbg , 4 , "%s: SDBTs %lu SDBs %lu\n" , __func__ ,
1770
+ sfb -> num_sdbt , sfb -> num_sdb );
1768
1771
1769
1772
return aux ;
1770
1773
0 commit comments