kernel

Linux kernel idle loop

夙愿已清 提交于 2019-12-24 02:53:04
问题 Inside the linux kernel idle loop, for quite a few architectures (SH, ARM, X86 etc.. afaik) are the following lines: if(cpuidle_idle_call()) pm_idle(); My doubt: At-least for ARM, The default pm_idle function consists of WFI (Wait for interrupt) instruction but the confusing part is, interrupts are disabled then and are enabled after the WFI instruction executes, How does a CPU get back online from WFI when interrupts were disabled ? I tried searching for my answers in various versions of

Cannot enable kernel dynamic debugging on linux

自古美人都是妖i 提交于 2019-12-24 02:35:29
问题 I have enabled the CONFIG_DYNAMIC_DEBUG flag in kernel config file, built & installed the kernel. Then, when I reboot, I can see /sys/kernel/debug/dynamic_debug/control . However, when I tried to dynamically enable a module like so: sudo echo 'module xhci_hcd +p' > /sys/kernel/debug/dynamic_debug/control I got: bash: /sys/kernel/debug/dynamic_debug/control: Permission denied Notice that I'm using sudo . 回答1: The redirection (with the > shell operator) is not performed as root. That's why you

what is the algorithm for an RBF kernel matrix in Matlab?

空扰寡人 提交于 2019-12-24 01:47:20
问题 If I am given training data sets and unlabeled datasets, what is the RBF Kernel matrix algorithm for Matlab? 回答1: This should be what you are looking for. It is taken from here % With Fast Computation of the RBF kernel matrix % To speed up the computation, we exploit a decomposition of the Euclidean distance (norm) % % Inputs: % ker: 'lin','poly','rbf','sam' % X: data matrix with training samples in rows and features in columns % X2: data matrix with test samples in rows and features in

What's wrong with vfs_stat() call?

廉价感情. 提交于 2019-12-24 01:44:58
问题 I'm trying to do a stat on files, struct kstat stat; int error = vfs_stat ("/bin/ls", &stat); // /bin/ls exists if (error) { printk (KERN_INFO "error code %d\n", error); } else { printk (KERN_INFO "mode of ls: %o\n", stat.mode); printk (KERN_INFO "owner of ls: %o\n", stat.uid); } return error; But error was always set to 14 (Bad Address), what's wrong with the code? I'm running 3.9 kernel. 回答1: vfs_stat() is defined as: int vfs_stat(const char __user *name, struct kstat *stat); and __user is

sys_readlink fails EFAULT - alternative

半城伤御伤魂 提交于 2019-12-24 01:27:35
问题 I have the filedescriptor and like to get the real path. Currently i call sys_readlink /proc/self/fd/<fd> which works sometimes, but often i get an error -14 (-EFAULT). Here some Code: fs = get_fs(); set_fs(KERNEL_DS); err = sys_readlink(path, buf, size-1); set_fs(fs); Is there an alternative (probably better) way to get the realpath from kernel? 回答1: Get it from the filep in the task struct, e.g. something like struct task_struct *task; struct files_struct *files; struct file *file; char buf

Detect file copying from kernel extension

岁酱吖の 提交于 2019-12-24 01:16:15
问题 I'm trying to build POC that identify file copying activity from kauth based kernel extension that using fileop scope callback. However, it seems that copying file involves two separate authentication operations (open src file from and create new file). My goal is rather simple, detect the new target file creation after it was filled with data, disregarding the nature of the source file (so I'll be able to read it for further analysis) According to my observation, it may possible to achieve

How to set seed value of kernel initializer (glorot_uniform) in Keras

依然范特西╮ 提交于 2019-12-24 00:54:56
问题 I'd like to set seed value of glorot_uniform kernel initializer in Keras. model.add(Dense(50, input_dim=self.state_size, activation='relu', kernel_initializer='glorot_uniform(seed=0)')) When I use above code, error message is below. ValueError: Unknown initializer: glorot_uniform(seed=0) If I remove "(seed=0)" like as below model.add(Dense(50, input_dim=self.state_size, activation='relu', kernel_initializer='glorot_uniform')) It works well without setting a seed value. How can I set a seed

printk - showing in message log but not in terminal for any kernel log level

不问归期 提交于 2019-12-24 00:54:47
问题 I'm doing some kernel modification and am trying to get printk to output information back to the console. I pass any kernel log level with it and do not properly get any response back on the console for even the highest log levels. I checked and the current log configuration for printk is 4 4 1 7. It prints properly each time to logs. I can use dmesg | less and see it appended to the log. But I can't return it to console properly using printk. I'm not sure that it matters but I use SSH to

What is the definition of I/O, and what actions are classified as I/O?

不打扰是莪最后的温柔 提交于 2019-12-23 23:18:46
问题 When I was studying about linux cache, I found that I've been using the term I/O without knowing its proper definition. I quote from someone who responded to me about Linux page cache, "Linux kernel populates (and uses) page cache when you are doing i/o, not when you open a file" Basically, I treated the term I/O as any sys command, but turns out opening a file is not considered I/O. Furthermore, the definition of I/O is rarely discussed or documented online. Which leads to my question. What

Why does this code works on Xcode simulator, but does not work on device?

家住魔仙堡 提交于 2019-12-23 21:07:19
问题 I'm really hoping, that someone explains it to me. I'm writing an app that uses it's device mac address, and this code perfectly works on the simulator, but does not work on a device. I got this code from the question Get router mac (without system call for ARP) in Objective-C #include <stdio.h> #include <sys/types.h> #include <stdio.h> #include <string.h> #include <sys/socket.h> #include <net/if_dl.h> #include <ifaddrs.h> #include <net/if_types.h> char* getMacAddress(char* macAddress, char*