Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 203251 Details for
Bug 301821
Incorrect CPU topology parsing
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Patch to avoid unnecessary lookups and small optimizations
d-irqbalance-cputree (text/plain), 3.82 KB, created by
Ulrich Drepper
on 2007-09-22 22:20:42 UTC
(
hide
)
Description:
Patch to avoid unnecessary lookups and small optimizations
Filename:
MIME Type:
Creator:
Ulrich Drepper
Created:
2007-09-22 22:20:42 UTC
Size:
3.82 KB
patch
obsolete
>--- irqbalance-0.55/cputree.c.old 2006-12-10 12:04:59.000000000 -0800 >+++ irqbalance-0.55/cputree.c 2007-09-22 15:06:01.000000000 -0700 >@@ -26,6 +26,8 @@ > > #define _GNU_SOURCE > >+#include <ctype.h> >+#include <fcntl.h> > #include <stdio.h> > #include <stdlib.h> > #include <unistd.h> >@@ -131,34 +133,30 @@ > } > > >-static void do_one_cpu(char *path) >+static void do_one_cpu(int dfd, char *d_name) > { > struct cpu_core *cpu; > FILE *file; > char new_path[PATH_MAX]; > > /* skip offline cpus */ >- snprintf(new_path, PATH_MAX, "%s/online", path); >- file = fopen(new_path, "r"); >- if (file) { >- char *line = NULL; >- size_t size = 0; >- if (getline(&line, &size, file)==0) >+ snprintf(new_path, PATH_MAX, "%s/online", d_name); >+ int fd = openat(dfd, new_path, O_RDONLY); >+ if (fd != -1) { >+ char buf[1]; >+ ssize_t n = read(fd, buf, sizeof(buf)); >+ close(fd); >+ if (n != sizeof(buf)) > return; >- fclose(file); >- if (line && line[0]=='0') { >- free(line); >+ if (buf[0] == '0') > return; >- } >- free(line); > } > >- cpu = malloc(sizeof(struct cpu_core)); >+ cpu = calloc(1, sizeof(struct cpu_core)); > if (!cpu) > return; >- memset(cpu, 0, sizeof(struct cpu_core)); > >- cpu->number = strtoul(&path[27], NULL, 10); >+ cpu->number = strtoul(&d_name[3], NULL, 10); > > cpu_set(cpu->number, cpu->mask); > >@@ -170,43 +168,45 @@ > return; > } > >+ char *line = NULL; >+ size_t size = 0; > > /* try to read the package mask; if it doesn't exist assume solitary */ >- snprintf(new_path, PATH_MAX, "%s/topology/core_siblings", path); >- file = fopen(new_path, "r"); >+ snprintf(new_path, PATH_MAX, "%s/topology/core_siblings", d_name); >+ fd = openat(dfd, new_path, O_RDONLY); >+ file = fd == -1 ? NULL : fdopen(fd, "r"); > cpu_set(cpu->number, cpu->package_mask); > if (file) { >- char *line = NULL; >- size_t size = 0; > if (getline(&line, &size, file)) > cpumask_parse_user(line, strlen(line), cpu->package_mask); > fclose(file); >- free(line); >- } >+ } else if (fd != -1) >+ close(fd); > > /* try to read the cache mask; if it doesn't exist assume solitary */ > /* We want the deepest cache level available so try index1 first, then index2 */ > cpu_set(cpu->number, cpu->cache_mask); >- snprintf(new_path, PATH_MAX, "%s/cache/index1/shared_cpu_map", path); >- file = fopen(new_path, "r"); >+ snprintf(new_path, PATH_MAX, "%s/cache/index1/shared_cpu_map", d_name); >+ fd = openat(dfd, new_path, O_RDONLY); >+ file = fd == -1 ? NULL : fdopen(fd, "r"); > if (file) { >- char *line = NULL; >- size_t size = 0; > if (getline(&line, &size, file)) > cpumask_parse_user(line, strlen(line), cpu->cache_mask); > fclose(file); >- free(line); >- } >- snprintf(new_path, PATH_MAX, "%s/cache/index2/shared_cpu_map", path); >- file = fopen(new_path, "r"); >+ } else if (fd != -1) >+ close(fd); >+ >+ snprintf(new_path, PATH_MAX, "%s/cache/index2/shared_cpu_map", d_name); >+ fd = openat(dfd, new_path, O_RDONLY); >+ file = fd == -1 ? NULL : fdopen(fd, "r"); > if (file) { >- char *line = NULL; >- size_t size = 0; > if (getline(&line, &size, file)) > cpumask_parse_user(line, strlen(line), cpu->cache_mask); > fclose(file); >- free(line); >- } >+ } else if (fd != -1) >+ close(fd); >+ >+ free(line); > > /* > blank out the banned cpus from the various masks so that interrupts >@@ -311,18 +311,19 @@ > { > DIR *dir; > struct dirent *entry; >+ int dfd; > > cpus_complement(unbanned_cpus, banned_cpus); > > dir = opendir("/sys/devices/system/cpu"); > if (!dir) > return; >+ dfd = dirfd(dir); > do { > entry = readdir(dir); >- if (entry && strlen(entry->d_name)>3 && strstr(entry->d_name,"cpu")) { >- char new_path[PATH_MAX]; >- sprintf(new_path, "/sys/devices/system/cpu/%s", entry->d_name); >- do_one_cpu(new_path); >+ if (entry && strlen(entry->d_name)>3 && memcmp(entry->d_name,"cpu",3) == 0 >+ && isdigit(entry->d_name[3])) { >+ do_one_cpu(dfd, entry->d_name); > } > } while (entry); > closedir(dir);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 301821
: 203251