diff options
author | Josh Stone <jistone@redhat.com> | 2010-03-17 19:06:56 -0700 |
---|---|---|
committer | Josh Stone <jistone@redhat.com> | 2010-03-17 19:09:40 -0700 |
commit | 5e0ae7b6e3fe6e739b03c3ab4ef675113e38350f (patch) | |
tree | 4f379043a5f64e7b219e3ebb952a1eae14217436 | |
parent | 61cbdef4a69f73155b2d1e2934729f6cc8338511 (diff) | |
download | systemtap-steved-5e0ae7b6e3fe6e739b03c3ab4ef675113e38350f.tar.gz systemtap-steved-5e0ae7b6e3fe6e739b03c3ab4ef675113e38350f.tar.xz systemtap-steved-5e0ae7b6e3fe6e739b03c3ab4ef675113e38350f.zip |
Preserve perf initialization errors
* runtime/perf.c (_stp_perf_init): Pass through ERR_PTRs, and create our
own -ENOMEM for allocation failures.
* tapset-perfmon.cxx (perf_derived_probe_group::emit_module_init): Check
IS_ERR for registration status.
-rw-r--r-- | runtime/perf.c | 10 | ||||
-rw-r--r-- | tapset-perfmon.cxx | 5 |
2 files changed, 10 insertions, 5 deletions
diff --git a/runtime/perf.c b/runtime/perf.c index 7f1aaf74..053e0880 100644 --- a/runtime/perf.c +++ b/runtime/perf.c @@ -32,17 +32,20 @@ static Perf *_stp_perf_init (struct perf_event_attr *attr, perf_overflow_handler_t callback, const char *pp, void (*ph) (struct context *) ) { + long rc = -EINVAL; int cpu; Perf *pe; pe = (Perf *) _stp_kmalloc (sizeof(Perf)); if (pe == NULL) - return NULL; + return ERR_PTR(-ENOMEM); /* allocate space for the event descriptor for each cpu */ pe->pd = (perfcpu *) _stp_alloc_percpu (sizeof(perfcpu)); - if (pe->pd == NULL) + if (pe->pd == NULL) { + rc = -ENOMEM; goto exit1; + } /* initialize event on each processor */ stp_for_each_cpu(cpu) { @@ -52,6 +55,7 @@ static Perf *_stp_perf_init (struct perf_event_attr *attr, callback); if (IS_ERR(*event)) { + rc = PTR_ERR(*event); *event = NULL; goto exit2; } @@ -69,7 +73,7 @@ exit2: _stp_free_percpu(pe->pd); exit1: _stp_kfree(pe); - return NULL; + return ERR_PTR(rc); } /** Delete performance event. diff --git a/tapset-perfmon.cxx b/tapset-perfmon.cxx index 05a2bcd8..5c2d73e8 100644 --- a/tapset-perfmon.cxx +++ b/tapset-perfmon.cxx @@ -152,8 +152,9 @@ perf_derived_probe_group::emit_module_init (systemtap_session& s) s.op->newline() << "for (i=0; i<" << probes.size() << "; i++) {"; s.op->newline(1) << "struct stap_perf_probe* stp = & stap_perf_probes [i];"; s.op->newline() << "stp->perf = _stp_perf_init(&stp->attr, stp->cb, stp->pp, stp->ph);"; - s.op->newline() << "if (stp->perf == NULL) {"; - s.op->newline(1) << "rc = -EINVAL;"; + s.op->newline() << "if (IS_ERR(stp->perf)) {"; + s.op->newline(1) << "rc = PTR_ERR(stp->perf);"; + s.op->newline() << "stp->perf = NULL;"; s.op->newline() << "probe_point = stp->pp;"; s.op->newline() << "for (j=0; j<i; j++) {"; s.op->newline(1) << "stp = & stap_perf_probes [j];"; |