PageRenderTime 1308ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/kernel/gcov/fs.c

https://github.com/Mengqi/linux-2.6
C | 790 lines | 531 code | 83 blank | 176 comment | 91 complexity | d573a630c6bc351947722aed873e2552 MD5 | raw file
  1. /*
  2. * This code exports profiling data as debugfs files to userspace.
  3. *
  4. * Copyright IBM Corp. 2009
  5. * Author(s): Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
  6. *
  7. * Uses gcc-internal data definitions.
  8. * Based on the gcov-kernel patch by:
  9. * Hubertus Franke <frankeh@us.ibm.com>
  10. * Nigel Hinds <nhinds@us.ibm.com>
  11. * Rajan Ravindran <rajancr@us.ibm.com>
  12. * Peter Oberparleiter <oberpar@linux.vnet.ibm.com>
  13. * Paul Larson
  14. * Yi CDL Yang
  15. */
  16. #define pr_fmt(fmt) "gcov: " fmt
  17. #include <linux/init.h>
  18. #include <linux/module.h>
  19. #include <linux/debugfs.h>
  20. #include <linux/fs.h>
  21. #include <linux/list.h>
  22. #include <linux/string.h>
  23. #include <linux/slab.h>
  24. #include <linux/mutex.h>
  25. #include <linux/seq_file.h>
  26. #include "gcov.h"
  27. /**
  28. * struct gcov_node - represents a debugfs entry
  29. * @list: list head for child node list
  30. * @children: child nodes
  31. * @all: list head for list of all nodes
  32. * @parent: parent node
  33. * @loaded_info: array of pointers to profiling data sets for loaded object
  34. * files.
  35. * @num_loaded: number of profiling data sets for loaded object files.
  36. * @unloaded_info: accumulated copy of profiling data sets for unloaded
  37. * object files. Used only when gcov_persist=1.
  38. * @dentry: main debugfs entry, either a directory or data file
  39. * @links: associated symbolic links
  40. * @name: data file basename
  41. *
  42. * struct gcov_node represents an entity within the gcov/ subdirectory
  43. * of debugfs. There are directory and data file nodes. The latter represent
  44. * the actual synthesized data file plus any associated symbolic links which
  45. * are needed by the gcov tool to work correctly.
  46. */
  47. struct gcov_node {
  48. struct list_head list;
  49. struct list_head children;
  50. struct list_head all;
  51. struct gcov_node *parent;
  52. struct gcov_info **loaded_info;
  53. struct gcov_info *unloaded_info;
  54. struct dentry *dentry;
  55. struct dentry **links;
  56. int num_loaded;
  57. char name[0];
  58. };
  59. static const char objtree[] = OBJTREE;
  60. static const char srctree[] = SRCTREE;
  61. static struct gcov_node root_node;
  62. static struct dentry *reset_dentry;
  63. static LIST_HEAD(all_head);
  64. static DEFINE_MUTEX(node_lock);
  65. /* If non-zero, keep copies of profiling data for unloaded modules. */
  66. static int gcov_persist = 1;
  67. static int __init gcov_persist_setup(char *str)
  68. {
  69. unsigned long val;
  70. if (strict_strtoul(str, 0, &val)) {
  71. pr_warning("invalid gcov_persist parameter '%s'\n", str);
  72. return 0;
  73. }
  74. gcov_persist = val;
  75. pr_info("setting gcov_persist to %d\n", gcov_persist);
  76. return 1;
  77. }
  78. __setup("gcov_persist=", gcov_persist_setup);
  79. /*
  80. * seq_file.start() implementation for gcov data files. Note that the
  81. * gcov_iterator interface is designed to be more restrictive than seq_file
  82. * (no start from arbitrary position, etc.), to simplify the iterator
  83. * implementation.
  84. */
  85. static void *gcov_seq_start(struct seq_file *seq, loff_t *pos)
  86. {
  87. loff_t i;
  88. gcov_iter_start(seq->private);
  89. for (i = 0; i < *pos; i++) {
  90. if (gcov_iter_next(seq->private))
  91. return NULL;
  92. }
  93. return seq->private;
  94. }
  95. /* seq_file.next() implementation for gcov data files. */
  96. static void *gcov_seq_next(struct seq_file *seq, void *data, loff_t *pos)
  97. {
  98. struct gcov_iterator *iter = data;
  99. if (gcov_iter_next(iter))
  100. return NULL;
  101. (*pos)++;
  102. return iter;
  103. }
  104. /* seq_file.show() implementation for gcov data files. */
  105. static int gcov_seq_show(struct seq_file *seq, void *data)
  106. {
  107. struct gcov_iterator *iter = data;
  108. if (gcov_iter_write(iter, seq))
  109. return -EINVAL;
  110. return 0;
  111. }
  112. static void gcov_seq_stop(struct seq_file *seq, void *data)
  113. {
  114. /* Unused. */
  115. }
  116. static const struct seq_operations gcov_seq_ops = {
  117. .start = gcov_seq_start,
  118. .next = gcov_seq_next,
  119. .show = gcov_seq_show,
  120. .stop = gcov_seq_stop,
  121. };
  122. /*
  123. * Return a profiling data set associated with the given node. This is
  124. * either a data set for a loaded object file or a data set copy in case
  125. * all associated object files have been unloaded.
  126. */
  127. static struct gcov_info *get_node_info(struct gcov_node *node)
  128. {
  129. if (node->num_loaded > 0)
  130. return node->loaded_info[0];
  131. return node->unloaded_info;
  132. }
  133. /*
  134. * Return a newly allocated profiling data set which contains the sum of
  135. * all profiling data associated with the given node.
  136. */
  137. static struct gcov_info *get_accumulated_info(struct gcov_node *node)
  138. {
  139. struct gcov_info *info;
  140. int i = 0;
  141. if (node->unloaded_info)
  142. info = gcov_info_dup(node->unloaded_info);
  143. else
  144. info = gcov_info_dup(node->loaded_info[i++]);
  145. if (!info)
  146. return NULL;
  147. for (; i < node->num_loaded; i++)
  148. gcov_info_add(info, node->loaded_info[i]);
  149. return info;
  150. }
  151. /*
  152. * open() implementation for gcov data files. Create a copy of the profiling
  153. * data set and initialize the iterator and seq_file interface.
  154. */
  155. static int gcov_seq_open(struct inode *inode, struct file *file)
  156. {
  157. struct gcov_node *node = inode->i_private;
  158. struct gcov_iterator *iter;
  159. struct seq_file *seq;
  160. struct gcov_info *info;
  161. int rc = -ENOMEM;
  162. mutex_lock(&node_lock);
  163. /*
  164. * Read from a profiling data copy to minimize reference tracking
  165. * complexity and concurrent access and to keep accumulating multiple
  166. * profiling data sets associated with one node simple.
  167. */
  168. info = get_accumulated_info(node);
  169. if (!info)
  170. goto out_unlock;
  171. iter = gcov_iter_new(info);
  172. if (!iter)
  173. goto err_free_info;
  174. rc = seq_open(file, &gcov_seq_ops);
  175. if (rc)
  176. goto err_free_iter_info;
  177. seq = file->private_data;
  178. seq->private = iter;
  179. out_unlock:
  180. mutex_unlock(&node_lock);
  181. return rc;
  182. err_free_iter_info:
  183. gcov_iter_free(iter);
  184. err_free_info:
  185. gcov_info_free(info);
  186. goto out_unlock;
  187. }
  188. /*
  189. * release() implementation for gcov data files. Release resources allocated
  190. * by open().
  191. */
  192. static int gcov_seq_release(struct inode *inode, struct file *file)
  193. {
  194. struct gcov_iterator *iter;
  195. struct gcov_info *info;
  196. struct seq_file *seq;
  197. seq = file->private_data;
  198. iter = seq->private;
  199. info = gcov_iter_get_info(iter);
  200. gcov_iter_free(iter);
  201. gcov_info_free(info);
  202. seq_release(inode, file);
  203. return 0;
  204. }
  205. /*
  206. * Find a node by the associated data file name. Needs to be called with
  207. * node_lock held.
  208. */
  209. static struct gcov_node *get_node_by_name(const char *name)
  210. {
  211. struct gcov_node *node;
  212. struct gcov_info *info;
  213. list_for_each_entry(node, &all_head, all) {
  214. info = get_node_info(node);
  215. if (info && (strcmp(info->filename, name) == 0))
  216. return node;
  217. }
  218. return NULL;
  219. }
  220. /*
  221. * Reset all profiling data associated with the specified node.
  222. */
  223. static void reset_node(struct gcov_node *node)
  224. {
  225. int i;
  226. if (node->unloaded_info)
  227. gcov_info_reset(node->unloaded_info);
  228. for (i = 0; i < node->num_loaded; i++)
  229. gcov_info_reset(node->loaded_info[i]);
  230. }
  231. static void remove_node(struct gcov_node *node);
  232. /*
  233. * write() implementation for gcov data files. Reset profiling data for the
  234. * corresponding file. If all associated object files have been unloaded,
  235. * remove the debug fs node as well.
  236. */
  237. static ssize_t gcov_seq_write(struct file *file, const char __user *addr,
  238. size_t len, loff_t *pos)
  239. {
  240. struct seq_file *seq;
  241. struct gcov_info *info;
  242. struct gcov_node *node;
  243. seq = file->private_data;
  244. info = gcov_iter_get_info(seq->private);
  245. mutex_lock(&node_lock);
  246. node = get_node_by_name(info->filename);
  247. if (node) {
  248. /* Reset counts or remove node for unloaded modules. */
  249. if (node->num_loaded == 0)
  250. remove_node(node);
  251. else
  252. reset_node(node);
  253. }
  254. /* Reset counts for open file. */
  255. gcov_info_reset(info);
  256. mutex_unlock(&node_lock);
  257. return len;
  258. }
  259. /*
  260. * Given a string <path> representing a file path of format:
  261. * path/to/file.gcda
  262. * construct and return a new string:
  263. * <dir/>path/to/file.<ext>
  264. */
  265. static char *link_target(const char *dir, const char *path, const char *ext)
  266. {
  267. char *target;
  268. char *old_ext;
  269. char *copy;
  270. copy = kstrdup(path, GFP_KERNEL);
  271. if (!copy)
  272. return NULL;
  273. old_ext = strrchr(copy, '.');
  274. if (old_ext)
  275. *old_ext = '\0';
  276. if (dir)
  277. target = kasprintf(GFP_KERNEL, "%s/%s.%s", dir, copy, ext);
  278. else
  279. target = kasprintf(GFP_KERNEL, "%s.%s", copy, ext);
  280. kfree(copy);
  281. return target;
  282. }
  283. /*
  284. * Construct a string representing the symbolic link target for the given
  285. * gcov data file name and link type. Depending on the link type and the
  286. * location of the data file, the link target can either point to a
  287. * subdirectory of srctree, objtree or in an external location.
  288. */
  289. static char *get_link_target(const char *filename, const struct gcov_link *ext)
  290. {
  291. const char *rel;
  292. char *result;
  293. if (strncmp(filename, objtree, strlen(objtree)) == 0) {
  294. rel = filename + strlen(objtree) + 1;
  295. if (ext->dir == SRC_TREE)
  296. result = link_target(srctree, rel, ext->ext);
  297. else
  298. result = link_target(objtree, rel, ext->ext);
  299. } else {
  300. /* External compilation. */
  301. result = link_target(NULL, filename, ext->ext);
  302. }
  303. return result;
  304. }
  305. #define SKEW_PREFIX ".tmp_"
  306. /*
  307. * For a filename .tmp_filename.ext return filename.ext. Needed to compensate
  308. * for filename skewing caused by the mod-versioning mechanism.
  309. */
  310. static const char *deskew(const char *basename)
  311. {
  312. if (strncmp(basename, SKEW_PREFIX, sizeof(SKEW_PREFIX) - 1) == 0)
  313. return basename + sizeof(SKEW_PREFIX) - 1;
  314. return basename;
  315. }
  316. /*
  317. * Create links to additional files (usually .c and .gcno files) which the
  318. * gcov tool expects to find in the same directory as the gcov data file.
  319. */
  320. static void add_links(struct gcov_node *node, struct dentry *parent)
  321. {
  322. char *basename;
  323. char *target;
  324. int num;
  325. int i;
  326. for (num = 0; gcov_link[num].ext; num++)
  327. /* Nothing. */;
  328. node->links = kcalloc(num, sizeof(struct dentry *), GFP_KERNEL);
  329. if (!node->links)
  330. return;
  331. for (i = 0; i < num; i++) {
  332. target = get_link_target(get_node_info(node)->filename,
  333. &gcov_link[i]);
  334. if (!target)
  335. goto out_err;
  336. basename = strrchr(target, '/');
  337. if (!basename)
  338. goto out_err;
  339. basename++;
  340. node->links[i] = debugfs_create_symlink(deskew(basename),
  341. parent, target);
  342. if (!node->links[i])
  343. goto out_err;
  344. kfree(target);
  345. }
  346. return;
  347. out_err:
  348. kfree(target);
  349. while (i-- > 0)
  350. debugfs_remove(node->links[i]);
  351. kfree(node->links);
  352. node->links = NULL;
  353. }
  354. static const struct file_operations gcov_data_fops = {
  355. .open = gcov_seq_open,
  356. .release = gcov_seq_release,
  357. .read = seq_read,
  358. .llseek = seq_lseek,
  359. .write = gcov_seq_write,
  360. };
  361. /* Basic initialization of a new node. */
  362. static void init_node(struct gcov_node *node, struct gcov_info *info,
  363. const char *name, struct gcov_node *parent)
  364. {
  365. INIT_LIST_HEAD(&node->list);
  366. INIT_LIST_HEAD(&node->children);
  367. INIT_LIST_HEAD(&node->all);
  368. if (node->loaded_info) {
  369. node->loaded_info[0] = info;
  370. node->num_loaded = 1;
  371. }
  372. node->parent = parent;
  373. if (name)
  374. strcpy(node->name, name);
  375. }
  376. /*
  377. * Create a new node and associated debugfs entry. Needs to be called with
  378. * node_lock held.
  379. */
  380. static struct gcov_node *new_node(struct gcov_node *parent,
  381. struct gcov_info *info, const char *name)
  382. {
  383. struct gcov_node *node;
  384. node = kzalloc(sizeof(struct gcov_node) + strlen(name) + 1, GFP_KERNEL);
  385. if (!node)
  386. goto err_nomem;
  387. if (info) {
  388. node->loaded_info = kcalloc(1, sizeof(struct gcov_info *),
  389. GFP_KERNEL);
  390. if (!node->loaded_info)
  391. goto err_nomem;
  392. }
  393. init_node(node, info, name, parent);
  394. /* Differentiate between gcov data file nodes and directory nodes. */
  395. if (info) {
  396. node->dentry = debugfs_create_file(deskew(node->name), 0600,
  397. parent->dentry, node, &gcov_data_fops);
  398. } else
  399. node->dentry = debugfs_create_dir(node->name, parent->dentry);
  400. if (!node->dentry) {
  401. pr_warning("could not create file\n");
  402. kfree(node);
  403. return NULL;
  404. }
  405. if (info)
  406. add_links(node, parent->dentry);
  407. list_add(&node->list, &parent->children);
  408. list_add(&node->all, &all_head);
  409. return node;
  410. err_nomem:
  411. kfree(node);
  412. pr_warning("out of memory\n");
  413. return NULL;
  414. }
  415. /* Remove symbolic links associated with node. */
  416. static void remove_links(struct gcov_node *node)
  417. {
  418. int i;
  419. if (!node->links)
  420. return;
  421. for (i = 0; gcov_link[i].ext; i++)
  422. debugfs_remove(node->links[i]);
  423. kfree(node->links);
  424. node->links = NULL;
  425. }
  426. /*
  427. * Remove node from all lists and debugfs and release associated resources.
  428. * Needs to be called with node_lock held.
  429. */
  430. static void release_node(struct gcov_node *node)
  431. {
  432. list_del(&node->list);
  433. list_del(&node->all);
  434. debugfs_remove(node->dentry);
  435. remove_links(node);
  436. kfree(node->loaded_info);
  437. if (node->unloaded_info)
  438. gcov_info_free(node->unloaded_info);
  439. kfree(node);
  440. }
  441. /* Release node and empty parents. Needs to be called with node_lock held. */
  442. static void remove_node(struct gcov_node *node)
  443. {
  444. struct gcov_node *parent;
  445. while ((node != &root_node) && list_empty(&node->children)) {
  446. parent = node->parent;
  447. release_node(node);
  448. node = parent;
  449. }
  450. }
  451. /*
  452. * Find child node with given basename. Needs to be called with node_lock
  453. * held.
  454. */
  455. static struct gcov_node *get_child_by_name(struct gcov_node *parent,
  456. const char *name)
  457. {
  458. struct gcov_node *node;
  459. list_for_each_entry(node, &parent->children, list) {
  460. if (strcmp(node->name, name) == 0)
  461. return node;
  462. }
  463. return NULL;
  464. }
  465. /*
  466. * write() implementation for reset file. Reset all profiling data to zero
  467. * and remove nodes for which all associated object files are unloaded.
  468. */
  469. static ssize_t reset_write(struct file *file, const char __user *addr,
  470. size_t len, loff_t *pos)
  471. {
  472. struct gcov_node *node;
  473. mutex_lock(&node_lock);
  474. restart:
  475. list_for_each_entry(node, &all_head, all) {
  476. if (node->num_loaded > 0)
  477. reset_node(node);
  478. else if (list_empty(&node->children)) {
  479. remove_node(node);
  480. /* Several nodes may have gone - restart loop. */
  481. goto restart;
  482. }
  483. }
  484. mutex_unlock(&node_lock);
  485. return len;
  486. }
  487. /* read() implementation for reset file. Unused. */
  488. static ssize_t reset_read(struct file *file, char __user *addr, size_t len,
  489. loff_t *pos)
  490. {
  491. /* Allow read operation so that a recursive copy won't fail. */
  492. return 0;
  493. }
  494. static const struct file_operations gcov_reset_fops = {
  495. .write = reset_write,
  496. .read = reset_read,
  497. .llseek = noop_llseek,
  498. };
  499. /*
  500. * Create a node for a given profiling data set and add it to all lists and
  501. * debugfs. Needs to be called with node_lock held.
  502. */
  503. static void add_node(struct gcov_info *info)
  504. {
  505. char *filename;
  506. char *curr;
  507. char *next;
  508. struct gcov_node *parent;
  509. struct gcov_node *node;
  510. filename = kstrdup(info->filename, GFP_KERNEL);
  511. if (!filename)
  512. return;
  513. parent = &root_node;
  514. /* Create directory nodes along the path. */
  515. for (curr = filename; (next = strchr(curr, '/')); curr = next + 1) {
  516. if (curr == next)
  517. continue;
  518. *next = 0;
  519. if (strcmp(curr, ".") == 0)
  520. continue;
  521. if (strcmp(curr, "..") == 0) {
  522. if (!parent->parent)
  523. goto err_remove;
  524. parent = parent->parent;
  525. continue;
  526. }
  527. node = get_child_by_name(parent, curr);
  528. if (!node) {
  529. node = new_node(parent, NULL, curr);
  530. if (!node)
  531. goto err_remove;
  532. }
  533. parent = node;
  534. }
  535. /* Create file node. */
  536. node = new_node(parent, info, curr);
  537. if (!node)
  538. goto err_remove;
  539. out:
  540. kfree(filename);
  541. return;
  542. err_remove:
  543. remove_node(parent);
  544. goto out;
  545. }
  546. /*
  547. * Associate a profiling data set with an existing node. Needs to be called
  548. * with node_lock held.
  549. */
  550. static void add_info(struct gcov_node *node, struct gcov_info *info)
  551. {
  552. struct gcov_info **loaded_info;
  553. int num = node->num_loaded;
  554. /*
  555. * Prepare new array. This is done first to simplify cleanup in
  556. * case the new data set is incompatible, the node only contains
  557. * unloaded data sets and there's not enough memory for the array.
  558. */
  559. loaded_info = kcalloc(num + 1, sizeof(struct gcov_info *), GFP_KERNEL);
  560. if (!loaded_info) {
  561. pr_warning("could not add '%s' (out of memory)\n",
  562. info->filename);
  563. return;
  564. }
  565. memcpy(loaded_info, node->loaded_info,
  566. num * sizeof(struct gcov_info *));
  567. loaded_info[num] = info;
  568. /* Check if the new data set is compatible. */
  569. if (num == 0) {
  570. /*
  571. * A module was unloaded, modified and reloaded. The new
  572. * data set replaces the copy of the last one.
  573. */
  574. if (!gcov_info_is_compatible(node->unloaded_info, info)) {
  575. pr_warning("discarding saved data for %s "
  576. "(incompatible version)\n", info->filename);
  577. gcov_info_free(node->unloaded_info);
  578. node->unloaded_info = NULL;
  579. }
  580. } else {
  581. /*
  582. * Two different versions of the same object file are loaded.
  583. * The initial one takes precedence.
  584. */
  585. if (!gcov_info_is_compatible(node->loaded_info[0], info)) {
  586. pr_warning("could not add '%s' (incompatible "
  587. "version)\n", info->filename);
  588. kfree(loaded_info);
  589. return;
  590. }
  591. }
  592. /* Overwrite previous array. */
  593. kfree(node->loaded_info);
  594. node->loaded_info = loaded_info;
  595. node->num_loaded = num + 1;
  596. }
  597. /*
  598. * Return the index of a profiling data set associated with a node.
  599. */
  600. static int get_info_index(struct gcov_node *node, struct gcov_info *info)
  601. {
  602. int i;
  603. for (i = 0; i < node->num_loaded; i++) {
  604. if (node->loaded_info[i] == info)
  605. return i;
  606. }
  607. return -ENOENT;
  608. }
  609. /*
  610. * Save the data of a profiling data set which is being unloaded.
  611. */
  612. static void save_info(struct gcov_node *node, struct gcov_info *info)
  613. {
  614. if (node->unloaded_info)
  615. gcov_info_add(node->unloaded_info, info);
  616. else {
  617. node->unloaded_info = gcov_info_dup(info);
  618. if (!node->unloaded_info) {
  619. pr_warning("could not save data for '%s' "
  620. "(out of memory)\n", info->filename);
  621. }
  622. }
  623. }
  624. /*
  625. * Disassociate a profiling data set from a node. Needs to be called with
  626. * node_lock held.
  627. */
  628. static void remove_info(struct gcov_node *node, struct gcov_info *info)
  629. {
  630. int i;
  631. i = get_info_index(node, info);
  632. if (i < 0) {
  633. pr_warning("could not remove '%s' (not found)\n",
  634. info->filename);
  635. return;
  636. }
  637. if (gcov_persist)
  638. save_info(node, info);
  639. /* Shrink array. */
  640. node->loaded_info[i] = node->loaded_info[node->num_loaded - 1];
  641. node->num_loaded--;
  642. if (node->num_loaded > 0)
  643. return;
  644. /* Last loaded data set was removed. */
  645. kfree(node->loaded_info);
  646. node->loaded_info = NULL;
  647. node->num_loaded = 0;
  648. if (!node->unloaded_info)
  649. remove_node(node);
  650. }
  651. /*
  652. * Callback to create/remove profiling files when code compiled with
  653. * -fprofile-arcs is loaded/unloaded.
  654. */
  655. void gcov_event(enum gcov_action action, struct gcov_info *info)
  656. {
  657. struct gcov_node *node;
  658. mutex_lock(&node_lock);
  659. node = get_node_by_name(info->filename);
  660. switch (action) {
  661. case GCOV_ADD:
  662. if (node)
  663. add_info(node, info);
  664. else
  665. add_node(info);
  666. break;
  667. case GCOV_REMOVE:
  668. if (node)
  669. remove_info(node, info);
  670. else {
  671. pr_warning("could not remove '%s' (not found)\n",
  672. info->filename);
  673. }
  674. break;
  675. }
  676. mutex_unlock(&node_lock);
  677. }
  678. /* Create debugfs entries. */
  679. static __init int gcov_fs_init(void)
  680. {
  681. int rc = -EIO;
  682. init_node(&root_node, NULL, NULL, NULL);
  683. /*
  684. * /sys/kernel/debug/gcov will be parent for the reset control file
  685. * and all profiling files.
  686. */
  687. root_node.dentry = debugfs_create_dir("gcov", NULL);
  688. if (!root_node.dentry)
  689. goto err_remove;
  690. /*
  691. * Create reset file which resets all profiling counts when written
  692. * to.
  693. */
  694. reset_dentry = debugfs_create_file("reset", 0600, root_node.dentry,
  695. NULL, &gcov_reset_fops);
  696. if (!reset_dentry)
  697. goto err_remove;
  698. /* Replay previous events to get our fs hierarchy up-to-date. */
  699. gcov_enable_events();
  700. return 0;
  701. err_remove:
  702. pr_err("init failed\n");
  703. if (root_node.dentry)
  704. debugfs_remove(root_node.dentry);
  705. return rc;
  706. }
  707. device_initcall(gcov_fs_init);