static int pfn_inject_init(void) { struct dentry *dentry; hwpoison_dir = debugfs_create_dir("hwpoison", NULL); if (hwpoison_dir == NULL) return -ENOMEM; /* * Note that the below poison/unpoison interfaces do not involve * hardware status change, hence do not require hardware support. * They are mainly for testing hwpoison in software level. */ dentry = debugfs_create_file("corrupt-pfn", 0600, hwpoison_dir, NULL, &hwpoison_fops); if (!dentry) goto fail; dentry = debugfs_create_file("unpoison-pfn", 0600, hwpoison_dir, NULL, &unpoison_fops); if (!dentry) goto fail; dentry = debugfs_create_u32("corrupt-filter-enable", 0600, hwpoison_dir, &hwpoison_filter_enable); if (!dentry) goto fail; dentry = debugfs_create_u32("corrupt-filter-dev-major", 0600, hwpoison_dir, &hwpoison_filter_dev_major); if (!dentry) goto fail; dentry = debugfs_create_u32("corrupt-filter-dev-minor", 0600, hwpoison_dir, &hwpoison_filter_dev_minor); if (!dentry) goto fail; dentry = debugfs_create_u64("corrupt-filter-flags-mask", 0600, hwpoison_dir, &hwpoison_filter_flags_mask); if (!dentry) goto fail; dentry = debugfs_create_u64("corrupt-filter-flags-value", 0600, hwpoison_dir, &hwpoison_filter_flags_value); if (!dentry) goto fail; #ifdef CONFIG_MEMCG_SWAP dentry = debugfs_create_u64("corrupt-filter-memcg", 0600, hwpoison_dir, &hwpoison_filter_memcg); if (!dentry) goto fail; #endif return 0; fail: pfn_inject_exit(); return -ENOMEM; }
static int __init zswap_debugfs_init(void) { if (!debugfs_initialized()) return -ENODEV; zswap_debugfs_root = debugfs_create_dir("zswap", NULL); if (!zswap_debugfs_root) return -ENOMEM; debugfs_create_u64("pool_limit_hit", S_IRUGO, zswap_debugfs_root, &zswap_pool_limit_hit); debugfs_create_u64("reject_reclaim_fail", S_IRUGO, zswap_debugfs_root, &zswap_reject_reclaim_fail); debugfs_create_u64("reject_alloc_fail", S_IRUGO, zswap_debugfs_root, &zswap_reject_alloc_fail); debugfs_create_u64("reject_kmemcache_fail", S_IRUGO, zswap_debugfs_root, &zswap_reject_kmemcache_fail); debugfs_create_u64("reject_compress_poor", S_IRUGO, zswap_debugfs_root, &zswap_reject_compress_poor); debugfs_create_u64("written_back_pages", S_IRUGO, zswap_debugfs_root, &zswap_written_back_pages); debugfs_create_u64("duplicate_entry", S_IRUGO, zswap_debugfs_root, &zswap_duplicate_entry); debugfs_create_u64("pool_total_size", S_IRUGO, zswap_debugfs_root, &zswap_pool_total_size); debugfs_create_u64("pool_pages", S_IRUGO, zswap_debugfs_root, &zswap_pool_pages); debugfs_create_atomic_t("stored_pages", S_IRUGO, zswap_debugfs_root, &zswap_stored_pages); debugfs_create_atomic_t("zero_pages", S_IRUGO, zswap_debugfs_root, &zswap_zero_pages); return 0; }
static int __init init_cleancache(void) { #ifdef CONFIG_DEBUG_FS struct dentry *root = debugfs_create_dir("cleancache", NULL); if (root == NULL) return -ENXIO; debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets); debugfs_create_u64("failed_gets", S_IRUGO, root, &cleancache_failed_gets); debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts); debugfs_create_u64("invalidates", S_IRUGO, root, &cleancache_invalidates); #endif return 0; }
int zcache_debugfs_init(void) { unsigned int i; struct dentry *root = debugfs_create_dir("zcache", NULL); if (root == NULL) return -ENXIO; for (i = 0; i < ARRAY_SIZE(attrs); i++) if (!debugfs_create_size_t(attrs[i].name, S_IRUGO, root, attrs[i].val)) goto out; debugfs_create_u64("eph_zbytes", S_IRUGO, root, &zcache_eph_zbytes); debugfs_create_u64("eph_zbytes_max", S_IRUGO, root, &zcache_eph_zbytes_max); debugfs_create_u64("pers_zbytes", S_IRUGO, root, &zcache_pers_zbytes); debugfs_create_u64("pers_zbytes_max", S_IRUGO, root, &zcache_pers_zbytes_max); return 0; out: return -ENODEV; }
static int __init init_cleancache(void) { int i; #ifdef CONFIG_DEBUG_FS struct dentry *root = debugfs_create_dir("cleancache", NULL); if (root == NULL) return -ENXIO; debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets); debugfs_create_u64("failed_gets", S_IRUGO, root, &cleancache_failed_gets); debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts); debugfs_create_u64("invalidates", S_IRUGO, root, &cleancache_invalidates); #endif for (i = 0; i < MAX_INITIALIZABLE_FS; i++) { fs_poolid_map[i] = FS_UNKNOWN; shared_fs_poolid_map[i] = FS_UNKNOWN; } return 0; }
static void bcm2835aux_debugfs_create(struct bcm2835aux_spi *bs, const char *dname) { char name[64]; struct dentry *dir; /* get full name */ snprintf(name, sizeof(name), "spi-bcm2835aux-%s", dname); /* the base directory */ dir = debugfs_create_dir(name, NULL); bs->debugfs_dir = dir; /* the counters */ debugfs_create_u64("count_transfer_polling", 0444, dir, &bs->count_transfer_polling); debugfs_create_u64("count_transfer_irq", 0444, dir, &bs->count_transfer_irq); debugfs_create_u64("count_transfer_irq_after_poll", 0444, dir, &bs->count_transfer_irq_after_poll); }
static int __init debugfs_test_init(void) { total_pages = (u64)vm_total_pages; root_entry = debugfs_create_dir("debugfs-root", NULL); if (!root_entry) { printk("Fail to create proc dir: debugfs-root\n"); return 1; } total_pages_entry = debugfs_create_u64("total_pages", 0644, root_entry, &total_pages); return 0; }
static int init_debug(void) { dir = debugfs_create_dir("eudyptula", NULL); if (!debugfs_create_file("id", 0666, dir, id_value, &fops_id)) { pr_err("Error creating id_file file"); return -ENODEV; } if (!debugfs_create_u64("jiffies", 0444, dir, (u64 *)&jiffies)) { pr_err("Error creating jiffies_file file"); return -ENODEV; } if (!debugfs_create_file("foo", 0644, dir, foo_value, &fops_foo)) { pr_err("Error creating foo_file file"); return -ENODEV; } return 0; }
struct dentry *esp_dump_var(const char *name, struct dentry *parent, void *value, esp_type type) { struct dentry *rc = NULL; umode_t mode = 0644; if(!esp_debugfs_root) return NULL; if(!parent) parent = esp_debugfs_root; switch(type) { case ESP_U8: rc = debugfs_create_u8(name, mode, parent, (u8*)value); break; case ESP_U16: rc = debugfs_create_u16(name, mode, parent, (u16*)value); break; case ESP_U32: rc = debugfs_create_u32(name, mode, parent, (u32*)value); break; case ESP_U64: rc = debugfs_create_u64(name, mode, parent, (u64*)value); break; case ESP_BOOL: rc = debugfs_create_bool(name, mode, parent, (u32*)value); break; default: //32 rc = debugfs_create_u32(name, mode, parent, (u32*)value); } if (!rc) goto Fail; else return rc; Fail: debugfs_remove_recursive(esp_debugfs_root); esp_debugfs_root = NULL; esp_dbg(ESP_DBG_ERROR, "%s failed, debugfs root removed; var name: %s\n", __FUNCTION__, name); return NULL; }
static int __init init_debug(void) { /* create a directory by the name dell in /sys/kernel/debugfs */ dirret = debugfs_create_dir("dell", NULL); /* create a file in the above directory This requires read and write file operations */ fileret = debugfs_create_file("text", 0644, dirret, &filevalue, &fops_debug); /* create a file which takes in a int(64) value */ u64int = debugfs_create_u64("number", 0644, dirret, &intvalue); if (!u64int) { printk("error creating int file"); return (-ENODEV); } /* takes a hex decimal value */ u64hex = debugfs_create_x64("hexnum", 0644, dirret, &hexvalue ); if (!u64hex) { printk("error creating hex file"); return (-ENODEV); } return (0); }
static void qca_debugfs_init(struct hci_dev *hdev) { struct hci_uart *hu = hci_get_drvdata(hdev); struct qca_data *qca = hu->priv; struct dentry *ibs_dir; umode_t mode; if (!hdev->debugfs) return; ibs_dir = debugfs_create_dir("ibs", hdev->debugfs); /* read only */ mode = S_IRUGO; debugfs_create_u8("tx_ibs_state", mode, ibs_dir, &qca->tx_ibs_state); debugfs_create_u8("rx_ibs_state", mode, ibs_dir, &qca->rx_ibs_state); debugfs_create_u64("ibs_sent_sleeps", mode, ibs_dir, &qca->ibs_sent_slps); debugfs_create_u64("ibs_sent_wakes", mode, ibs_dir, &qca->ibs_sent_wakes); debugfs_create_u64("ibs_sent_wake_acks", mode, ibs_dir, &qca->ibs_sent_wacks); debugfs_create_u64("ibs_recv_sleeps", mode, ibs_dir, &qca->ibs_recv_slps); debugfs_create_u64("ibs_recv_wakes", mode, ibs_dir, &qca->ibs_recv_wakes); debugfs_create_u64("ibs_recv_wake_acks", mode, ibs_dir, &qca->ibs_recv_wacks); debugfs_create_bool("tx_vote", mode, ibs_dir, &qca->tx_vote); debugfs_create_u64("tx_votes_on", mode, ibs_dir, &qca->tx_votes_on); debugfs_create_u64("tx_votes_off", mode, ibs_dir, &qca->tx_votes_off); debugfs_create_bool("rx_vote", mode, ibs_dir, &qca->rx_vote); debugfs_create_u64("rx_votes_on", mode, ibs_dir, &qca->rx_votes_on); debugfs_create_u64("rx_votes_off", mode, ibs_dir, &qca->rx_votes_off); debugfs_create_u64("votes_on", mode, ibs_dir, &qca->votes_on); debugfs_create_u64("votes_off", mode, ibs_dir, &qca->votes_off); debugfs_create_u32("vote_on_ms", mode, ibs_dir, &qca->vote_on_ms); debugfs_create_u32("vote_off_ms", mode, ibs_dir, &qca->vote_off_ms); /* read/write */ mode = S_IRUGO | S_IWUSR; debugfs_create_u32("wake_retrans", mode, ibs_dir, &qca->wake_retrans); debugfs_create_u32("tx_idle_delay", mode, ibs_dir, &qca->tx_idle_delay); }
/* * "Get" data from cleancache associated with the poolid/inode/index * that were specified when the data was put to cleanache and, if * successful, use it to fill the specified page with data and return 0. * The pageframe is unchanged and returns -1 if the get fails. * Page must be locked by caller. */ int __cleancache_get_page(struct page *page) { int ret = -1; int pool_id; struct cleancache_filekey key = { .u.key = { 0 } }; VM_BUG_ON(!PageLocked(page)); pool_id = page->mapping->host->i_sb->cleancache_poolid; if (pool_id < 0) goto out; if (cleancache_get_key(page->mapping->host, &key) < 0) goto out; ret = (*cleancache_ops.get_page)(pool_id, key, page->index, page); if (ret == 0) cleancache_succ_gets++; else cleancache_failed_gets++; out: return ret; } EXPORT_SYMBOL(__cleancache_get_page); /* * "Put" data from a page to cleancache and associate it with the * (previously-obtained per-filesystem) poolid and the page's, * inode and page index. Page must be locked. Note that a put_page * always "succeeds", though a subsequent get_page may succeed or fail. */ void __cleancache_put_page(struct page *page) { int pool_id; struct cleancache_filekey key = { .u.key = { 0 } }; VM_BUG_ON(!PageLocked(page)); pool_id = page->mapping->host->i_sb->cleancache_poolid; if (pool_id >= 0 && cleancache_get_key(page->mapping->host, &key) >= 0) { (*cleancache_ops.put_page)(pool_id, key, page->index, page); cleancache_puts++; } } EXPORT_SYMBOL(__cleancache_put_page); /* * Invalidate any data from cleancache associated with the poolid and the * page's inode and page index so that a subsequent "get" will fail. */ void __cleancache_invalidate_page(struct address_space *mapping, struct page *page) { /* careful... page->mapping is NULL sometimes when this is called */ int pool_id = mapping->host->i_sb->cleancache_poolid; struct cleancache_filekey key = { .u.key = { 0 } }; if (pool_id >= 0) { VM_BUG_ON(!PageLocked(page)); if (cleancache_get_key(mapping->host, &key) >= 0) { (*cleancache_ops.invalidate_page)(pool_id, key, page->index); cleancache_invalidates++; } } } EXPORT_SYMBOL(__cleancache_invalidate_page); /* * Invalidate all data from cleancache associated with the poolid and the * mappings's inode so that all subsequent gets to this poolid/inode * will fail. */ void __cleancache_invalidate_inode(struct address_space *mapping) { int pool_id = mapping->host->i_sb->cleancache_poolid; struct cleancache_filekey key = { .u.key = { 0 } }; if (pool_id >= 0 && cleancache_get_key(mapping->host, &key) >= 0) (*cleancache_ops.invalidate_inode)(pool_id, key); } EXPORT_SYMBOL(__cleancache_invalidate_inode); /* * Called by any cleancache-enabled filesystem at time of unmount; * note that pool_id is surrendered and may be reutrned by a subsequent * cleancache_init_fs or cleancache_init_shared_fs */ void __cleancache_invalidate_fs(struct super_block *sb) { if (sb->cleancache_poolid >= 0) { int old_poolid = sb->cleancache_poolid; sb->cleancache_poolid = -1; (*cleancache_ops.invalidate_fs)(old_poolid); } } EXPORT_SYMBOL(__cleancache_invalidate_fs); static int __init init_cleancache(void) { #ifdef CONFIG_DEBUG_FS struct dentry *root = debugfs_create_dir("cleancache", NULL); if (root == NULL) return -ENXIO; debugfs_create_u64("succ_gets", S_IRUGO, root, &cleancache_succ_gets); debugfs_create_u64("failed_gets", S_IRUGO, root, &cleancache_failed_gets); debugfs_create_u64("puts", S_IRUGO, root, &cleancache_puts); debugfs_create_u64("invalidates", S_IRUGO, root, &cleancache_invalidates); #endif return 0; } module_init(init_cleancache)
int netfront_accel_debugfs_create(netfront_accel_vnic *vnic) { #if defined(CONFIG_DEBUG_FS) if (sfc_debugfs_root == NULL) return -ENOENT; vnic->dbfs_dir = debugfs_create_dir(vnic->net_dev->name, sfc_debugfs_root); if (vnic->dbfs_dir == NULL) return -ENOMEM; vnic->netdev_dbfs.fastpath_rx_pkts = debugfs_create_u32 ("fastpath_rx_pkts", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->netdev_stats.fastpath_rx_pkts); vnic->netdev_dbfs.fastpath_rx_bytes = debugfs_create_u32 ("fastpath_rx_bytes", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->netdev_stats.fastpath_rx_bytes); vnic->netdev_dbfs.fastpath_rx_errors = debugfs_create_u32 ("fastpath_rx_errors", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->netdev_stats.fastpath_rx_errors); vnic->netdev_dbfs.fastpath_tx_pkts = debugfs_create_u32 ("fastpath_tx_pkts", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->netdev_stats.fastpath_tx_pkts); vnic->netdev_dbfs.fastpath_tx_bytes = debugfs_create_u32 ("fastpath_tx_bytes", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->netdev_stats.fastpath_tx_bytes); vnic->netdev_dbfs.fastpath_tx_errors = debugfs_create_u32 ("fastpath_tx_errors", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->netdev_stats.fastpath_tx_errors); #if NETFRONT_ACCEL_STATS vnic->dbfs.irq_count = debugfs_create_u64 ("irq_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.irq_count); vnic->dbfs.useless_irq_count = debugfs_create_u64 ("useless_irq_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.useless_irq_count); vnic->dbfs.poll_schedule_count = debugfs_create_u64 ("poll_schedule_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.poll_schedule_count); vnic->dbfs.poll_call_count = debugfs_create_u64 ("poll_call_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.poll_call_count); vnic->dbfs.poll_reschedule_count = debugfs_create_u64 ("poll_reschedule_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.poll_reschedule_count); vnic->dbfs.queue_stops = debugfs_create_u64 ("queue_stops", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.queue_stops); vnic->dbfs.queue_wakes = debugfs_create_u64 ("queue_wakes", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.queue_wakes); vnic->dbfs.ssr_bursts = debugfs_create_u64 ("ssr_bursts", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_bursts); vnic->dbfs.ssr_drop_stream = debugfs_create_u64 ("ssr_drop_stream", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_drop_stream); vnic->dbfs.ssr_misorder = debugfs_create_u64 ("ssr_misorder", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_misorder); vnic->dbfs.ssr_slow_start = debugfs_create_u64 ("ssr_slow_start", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_slow_start); vnic->dbfs.ssr_merges = debugfs_create_u64 ("ssr_merges", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_merges); vnic->dbfs.ssr_too_many = debugfs_create_u64 ("ssr_too_many", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_too_many); vnic->dbfs.ssr_new_stream = debugfs_create_u64 ("ssr_new_stream", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.ssr_new_stream); vnic->dbfs.fastpath_tx_busy = debugfs_create_u64 ("fastpath_tx_busy", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_tx_busy); vnic->dbfs.fastpath_tx_completions = debugfs_create_u64 ("fastpath_tx_completions", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_tx_completions); vnic->dbfs.fastpath_tx_pending_max = debugfs_create_u32 ("fastpath_tx_pending_max", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_tx_pending_max); vnic->dbfs.event_count = debugfs_create_u64 ("event_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.event_count); vnic->dbfs.bad_event_count = debugfs_create_u64 ("bad_event_count", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.bad_event_count); vnic->dbfs.event_count_since_irq = debugfs_create_u32 ("event_count_since_irq", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.event_count_since_irq); vnic->dbfs.events_per_irq_max = debugfs_create_u32 ("events_per_irq_max", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.events_per_irq_max); vnic->dbfs.fastpath_frm_trunc = debugfs_create_u64 ("fastpath_frm_trunc", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_frm_trunc); vnic->dbfs.fastpath_crc_bad = debugfs_create_u64 ("fastpath_crc_bad", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_crc_bad); vnic->dbfs.fastpath_csum_bad = debugfs_create_u64 ("fastpath_csum_bad", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_csum_bad); vnic->dbfs.fastpath_rights_bad = debugfs_create_u64 ("fastpath_rights_bad", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_rights_bad); vnic->dbfs.fastpath_discard_other = debugfs_create_u64 ("fastpath_discard_other", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.fastpath_discard_other); vnic->dbfs.rx_no_desc_trunc = debugfs_create_u64 ("rx_no_desc_trunc", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.rx_no_desc_trunc); vnic->dbfs.events_per_poll_max = debugfs_create_u32 ("events_per_poll_max", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.events_per_poll_max); vnic->dbfs.events_per_poll_rx_max = debugfs_create_u32 ("events_per_poll_rx_max", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.events_per_poll_rx_max); vnic->dbfs.events_per_poll_tx_max = debugfs_create_u32 ("events_per_poll_tx_max", S_IRUSR | S_IRGRP | S_IROTH, vnic->dbfs_dir, &vnic->stats.events_per_poll_tx_max); #endif #endif return 0; }