Lines Matching full:node
33 * @list: list head for child node list
36 * @parent: parent node
141 * Return a profiling data set associated with the given node. This is
145 static struct gcov_info *get_node_info(struct gcov_node *node) in get_node_info() argument
147 if (node->num_loaded > 0) in get_node_info()
148 return node->loaded_info[0]; in get_node_info()
150 return node->unloaded_info; in get_node_info()
155 * all profiling data associated with the given node.
157 static struct gcov_info *get_accumulated_info(struct gcov_node *node) in get_accumulated_info() argument
162 if (node->unloaded_info) in get_accumulated_info()
163 info = gcov_info_dup(node->unloaded_info); in get_accumulated_info()
165 info = gcov_info_dup(node->loaded_info[i++]); in get_accumulated_info()
168 for (; i < node->num_loaded; i++) in get_accumulated_info()
169 gcov_info_add(info, node->loaded_info[i]); in get_accumulated_info()
180 struct gcov_node *node = inode->i_private; in gcov_seq_open() local
190 * profiling data sets associated with one node simple. in gcov_seq_open()
192 info = get_accumulated_info(node); in gcov_seq_open()
235 * Find a node by the associated data file name. Needs to be called with
240 struct gcov_node *node; in get_node_by_name() local
243 list_for_each_entry(node, &all_head, all) { in get_node_by_name()
244 info = get_node_info(node); in get_node_by_name()
246 return node; in get_node_by_name()
253 * Reset all profiling data associated with the specified node.
255 static void reset_node(struct gcov_node *node) in reset_node() argument
259 if (node->unloaded_info) in reset_node()
260 gcov_info_reset(node->unloaded_info); in reset_node()
261 for (i = 0; i < node->num_loaded; i++) in reset_node()
262 gcov_info_reset(node->loaded_info[i]); in reset_node()
265 static void remove_node(struct gcov_node *node);
270 * remove the debug fs node as well.
277 struct gcov_node *node; in gcov_seq_write() local
282 node = get_node_by_name(gcov_info_filename(info)); in gcov_seq_write()
283 if (node) { in gcov_seq_write()
284 /* Reset counts or remove node for unloaded modules. */ in gcov_seq_write()
285 if (node->num_loaded == 0) in gcov_seq_write()
286 remove_node(node); in gcov_seq_write()
288 reset_node(node); in gcov_seq_write()
366 static void add_links(struct gcov_node *node, struct dentry *parent) in add_links() argument
375 node->links = kcalloc(num, sizeof(struct dentry *), GFP_KERNEL); in add_links()
376 if (!node->links) in add_links()
380 gcov_info_filename(get_node_info(node)), in add_links()
387 node->links[i] = debugfs_create_symlink(deskew(basename), in add_links()
396 debugfs_remove(node->links[i]); in add_links()
397 kfree(node->links); in add_links()
398 node->links = NULL; in add_links()
409 /* Basic initialization of a new node. */
410 static void init_node(struct gcov_node *node, struct gcov_info *info, in init_node() argument
413 INIT_LIST_HEAD(&node->list); in init_node()
414 INIT_LIST_HEAD(&node->children); in init_node()
415 INIT_LIST_HEAD(&node->all); in init_node()
416 if (node->loaded_info) { in init_node()
417 node->loaded_info[0] = info; in init_node()
418 node->num_loaded = 1; in init_node()
420 node->parent = parent; in init_node()
422 strcpy(node->name, name); in init_node()
426 * Create a new node and associated debugfs entry. Needs to be called with
432 struct gcov_node *node; in new_node() local
434 node = kzalloc(sizeof(struct gcov_node) + strlen(name) + 1, GFP_KERNEL); in new_node()
435 if (!node) in new_node()
438 node->loaded_info = kcalloc(1, sizeof(struct gcov_info *), in new_node()
440 if (!node->loaded_info) in new_node()
443 init_node(node, info, name, parent); in new_node()
446 node->dentry = debugfs_create_file(deskew(node->name), 0600, in new_node()
447 parent->dentry, node, &gcov_data_fops); in new_node()
449 node->dentry = debugfs_create_dir(node->name, parent->dentry); in new_node()
451 add_links(node, parent->dentry); in new_node()
452 list_add(&node->list, &parent->children); in new_node()
453 list_add(&node->all, &all_head); in new_node()
455 return node; in new_node()
458 kfree(node); in new_node()
463 /* Remove symbolic links associated with node. */
464 static void remove_links(struct gcov_node *node) in remove_links() argument
468 if (!node->links) in remove_links()
471 debugfs_remove(node->links[i]); in remove_links()
472 kfree(node->links); in remove_links()
473 node->links = NULL; in remove_links()
477 * Remove node from all lists and debugfs and release associated resources.
480 static void release_node(struct gcov_node *node) in release_node() argument
482 list_del(&node->list); in release_node()
483 list_del(&node->all); in release_node()
484 debugfs_remove(node->dentry); in release_node()
485 remove_links(node); in release_node()
486 kfree(node->loaded_info); in release_node()
487 if (node->unloaded_info) in release_node()
488 gcov_info_free(node->unloaded_info); in release_node()
489 kfree(node); in release_node()
492 /* Release node and empty parents. Needs to be called with node_lock held. */
493 static void remove_node(struct gcov_node *node) in remove_node() argument
497 while ((node != &root_node) && list_empty(&node->children)) { in remove_node()
498 parent = node->parent; in remove_node()
499 release_node(node); in remove_node()
500 node = parent; in remove_node()
505 * Find child node with given basename. Needs to be called with node_lock
511 struct gcov_node *node; in get_child_by_name() local
513 list_for_each_entry(node, &parent->children, list) { in get_child_by_name()
514 if (strcmp(node->name, name) == 0) in get_child_by_name()
515 return node; in get_child_by_name()
528 struct gcov_node *node; in reset_write() local
532 list_for_each_entry(node, &all_head, all) { in reset_write()
533 if (node->num_loaded > 0) in reset_write()
534 reset_node(node); in reset_write()
535 else if (list_empty(&node->children)) { in reset_write()
536 remove_node(node); in reset_write()
561 * Create a node for a given profiling data set and add it to all lists and
570 struct gcov_node *node; in add_node() local
589 node = get_child_by_name(parent, curr); in add_node()
590 if (!node) { in add_node()
591 node = new_node(parent, NULL, curr); in add_node()
592 if (!node) in add_node()
595 parent = node; in add_node()
597 /* Create file node. */ in add_node()
598 node = new_node(parent, info, curr); in add_node()
599 if (!node) in add_node()
611 * Associate a profiling data set with an existing node. Needs to be called
614 static void add_info(struct gcov_node *node, struct gcov_info *info) in add_info() argument
617 int num = node->num_loaded; in add_info()
621 * case the new data set is incompatible, the node only contains in add_info()
630 memcpy(loaded_info, node->loaded_info, in add_info()
639 if (!gcov_info_is_compatible(node->unloaded_info, info)) { in add_info()
643 gcov_info_free(node->unloaded_info); in add_info()
644 node->unloaded_info = NULL; in add_info()
651 if (!gcov_info_is_compatible(node->loaded_info[0], info)) { in add_info()
659 kfree(node->loaded_info); in add_info()
660 node->loaded_info = loaded_info; in add_info()
661 node->num_loaded = num + 1; in add_info()
665 * Return the index of a profiling data set associated with a node.
667 static int get_info_index(struct gcov_node *node, struct gcov_info *info) in get_info_index() argument
671 for (i = 0; i < node->num_loaded; i++) { in get_info_index()
672 if (node->loaded_info[i] == info) in get_info_index()
681 static void save_info(struct gcov_node *node, struct gcov_info *info) in save_info() argument
683 if (node->unloaded_info) in save_info()
684 gcov_info_add(node->unloaded_info, info); in save_info()
686 node->unloaded_info = gcov_info_dup(info); in save_info()
687 if (!node->unloaded_info) { in save_info()
696 * Disassociate a profiling data set from a node. Needs to be called with
699 static void remove_info(struct gcov_node *node, struct gcov_info *info) in remove_info() argument
703 i = get_info_index(node, info); in remove_info()
710 save_info(node, info); in remove_info()
712 node->loaded_info[i] = node->loaded_info[node->num_loaded - 1]; in remove_info()
713 node->num_loaded--; in remove_info()
714 if (node->num_loaded > 0) in remove_info()
717 kfree(node->loaded_info); in remove_info()
718 node->loaded_info = NULL; in remove_info()
719 node->num_loaded = 0; in remove_info()
720 if (!node->unloaded_info) in remove_info()
721 remove_node(node); in remove_info()
730 struct gcov_node *node; in gcov_event() local
733 node = get_node_by_name(gcov_info_filename(info)); in gcov_event()
736 if (node) in gcov_event()
737 add_info(node, info); in gcov_event()
742 if (node) in gcov_event()
743 remove_info(node, info); in gcov_event()