Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

s390/pai_crypto: replace atomic_t with refcount_t

The s390 PMU of PAI crypto counters uses atomic_t for reference
counting. Replace this with the proper data type refcount_t.

No functional change.

Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>

authored by

Thomas Richter and committed by
Alexander Gordeev
ecc758ce f1fcbaa1

+11 -8
+11 -8
arch/s390/kernel/perf_pai_crypto.c
··· 36 36 unsigned long *page; /* Page for CPU to store counters */ 37 37 struct pai_userdata *save; /* Page to store no-zero counters */ 38 38 unsigned int active_events; /* # of PAI crypto users */ 39 - unsigned int refcnt; /* Reference count mapped buffers */ 39 + refcount_t refcnt; /* Reference count mapped buffers */ 40 40 enum paievt_mode mode; /* Type of event */ 41 41 struct perf_event *event; /* Perf event for sampling */ 42 42 }; ··· 57 57 static_branch_dec(&pai_key); 58 58 mutex_lock(&pai_reserve_mutex); 59 59 debug_sprintf_event(cfm_dbg, 5, "%s event %#llx cpu %d users %d" 60 - " mode %d refcnt %d\n", __func__, 60 + " mode %d refcnt %u\n", __func__, 61 61 event->attr.config, event->cpu, 62 - cpump->active_events, cpump->mode, cpump->refcnt); 63 - if (!--cpump->refcnt) { 62 + cpump->active_events, cpump->mode, 63 + refcount_read(&cpump->refcnt)); 64 + if (refcount_dec_and_test(&cpump->refcnt)) { 64 65 debug_sprintf_event(cfm_dbg, 4, "%s page %#lx save %p\n", 65 66 __func__, (unsigned long)cpump->page, 66 67 cpump->save); ··· 150 149 /* Allocate memory for counter page and counter extraction. 151 150 * Only the first counting event has to allocate a page. 152 151 */ 153 - if (cpump->page) 152 + if (cpump->page) { 153 + refcount_inc(&cpump->refcnt); 154 154 goto unlock; 155 + } 155 156 156 157 rc = -ENOMEM; 157 158 cpump->page = (unsigned long *)get_zeroed_page(GFP_KERNEL); ··· 167 164 goto unlock; 168 165 } 169 166 rc = 0; 167 + refcount_set(&cpump->refcnt, 1); 170 168 171 169 unlock: 172 170 /* If rc is non-zero, do not set mode and reference count */ 173 171 if (!rc) { 174 - cpump->refcnt++; 175 172 cpump->mode = a->sample_period ? PAI_MODE_SAMPLING 176 173 : PAI_MODE_COUNTING; 177 174 } 178 175 debug_sprintf_event(cfm_dbg, 5, "%s sample_period %#llx users %d" 179 - " mode %d refcnt %d page %#lx save %p rc %d\n", 176 + " mode %d refcnt %u page %#lx save %p rc %d\n", 180 177 __func__, a->sample_period, cpump->active_events, 181 - cpump->mode, cpump->refcnt, 178 + cpump->mode, refcount_read(&cpump->refcnt), 182 179 (unsigned long)cpump->page, cpump->save, rc); 183 180 mutex_unlock(&pai_reserve_mutex); 184 181 return rc;