HOMECOURSESSTUDENTSDONATIONSVIDEOSEVENTSTUTORIALSLINKSNEWSCONTACT


VIDEOS 》 Linux Kernel Programming

Refer:
Wiki:
Kernel panic - https://en.wikipedia.org/wiki/Kernel_panic
kdump - https://en.wikipedia.org/wiki/Kdump_(Linux)
Segmentation fault - https://en.wikipedia.org/wiki/Segmentation_fault

Download this episode my entire kernel module sample code, make file, clean script HERE. And here is the source code for a quick reference.

/* kmalloc_vs_vmalloc 
 * The Linux Channel
 * Author: Kiran Kankipati
 * Updated: 23-nov-2016
 */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/fs.h>
#include <linux/vmalloc.h>
#include <asm/uaccess.h>


MODULE_LICENSE("GPL");
MODULE_AUTHOR("Kiran Kankipati");
MODULE_DESCRIPTION("kmalloc vs vmalloc");
MODULE_VERSION("0.1");

unsigned char *kmallocbuf;
unsigned char *vmallocbuf;

#define BUFLEN 1000

static int __init kmalloc_vs_vmalloc_init(void)
{	unsigned long js, je, jdiff;
	int i=0,j=0;
   kmallocbuf = kmalloc( BUFLEN, GFP_KERNEL);
   if(kmallocbuf)
   {	sprintf(kmallocbuf, "This is a test (kmallocbuf)\n");
     	printk("%s", kmallocbuf);
     	
     	js = jiffies;
     	for(j=0;j<100000;j++){ for(i=0;i<BUFLEN;i++) { kmallocbuf[i] = i+j; } }
     	je = jiffies;
     	printk("dummy print kmallocbuf: %02x\n", kmallocbuf[15]);
     	jdiff = je - js;
     	printk("\nEnd Time [%lu] - Start Time [%lu] - Diff [%lu]\n",je,js, jdiff);
   }
   printk("-------------------------------\n");
   
   vmallocbuf = vmalloc(BUFLEN);
   if(vmallocbuf)
   {	sprintf(vmallocbuf, "This is a test (vmallocbuf)\n");
   	printk("%s", vmallocbuf);
   	
   	js = jiffies;
   	for(j=0;j<100000;j++){ for(i=0;i<BUFLEN;i++) { vmallocbuf[i] = i+j; } }
     	je = jiffies;
     	printk("dummy print vmallocbuf: %02x\n", vmallocbuf[15]);
     	jdiff = je - js;
     	printk("\nEnd Time [%lu] - Start Time [%lu] - Diff [%lu]\n",je,js, jdiff);
   }
   return 0;
}


static void __exit kmalloc_vs_vmalloc_exit(void)
{	
   kfree(kmallocbuf);
   vfree(vmallocbuf);
}

module_init(kmalloc_vs_vmalloc_init);
module_exit(kmalloc_vs_vmalloc_exit);



Suggested Topics:


Video Episodes :: Linux Kernel programming

Linux Kernel FileSystems Subsystem ↗
Wednesday' 15-Jul-2020

Linux Kernel - Containers and Namespaces ↗
Wednesday' 15-Jul-2020

Linux Kernel Compilation ↗
Wednesday' 15-Jul-2020

Linux ioctl() API interface ↗
Wednesday' 15-Jul-2020
Watch detailed videos and read topics on Linux Kernel Programming and Linux ioctl() API interface

Linux Kernel Architecture ↗
Wednesday' 15-Jul-2020

Linux Kernel Programming ↗
Wednesday' 15-Jul-2020

Linux Operating System - User-space Processes ↗
Wednesday' 15-Jul-2020

Linux Kernel Programming - Device Drivers ↗
Wednesday' 15-Jul-2020
Watch detailed videos and read topics on Linux Kernel Programming - Device Drivers

Linux Kernel /proc Interface ↗
Wednesday' 15-Jul-2020

Join The Linux Channel :: Facebook Group ↗

Visit The Linux Channel :: on Youtube ↗


Join a course:

💎 Linux, Kernel, Networking and Device Drivers: PDF Brochure
💎 PhD or equivalent (or Post Doctoral) looking for assistance: Details
💎 ... or unlimited life-time mentorship: Details


💗 Help shape the future: Sponsor/Donate


Recommended Topics:
Featured Video:
Watch on Youtube - [224//0] 0x1f7 Programming Language Performance and Overheads | Part 1 | #TheLinuxChannel #Programming ↗

Roadmap - How to become Linux Kernel Developer - Device Drivers Programmer and a Systems Software Expert ↗
Wednesday' 15-Jul-2020
Many viewers and even sometimes my students ask me how I can become a kernel programmer or just device driver developer and so on. So I shot this video (and an add-on video) where I summarized steps and a roadmap to become a full-fledged Linux Kernel Developer.

Linux Kernel Module to Drop Packets captured via netfilter hooks ↗
Wednesday' 15-Jul-2020
Here is my sample Kernel Module to drop packets (i.e sk_buff instance) captured via netfilter hooks. When you want to drop packets in your custom netfilter hooks make sure you never do a manual kfree_skb(skb) API call. Since it is anyway performed once the flow of the code moves out of your kernel module netfilter hook. All you need to do is to return NF_DROP to drop gracefully the desired packet. Here is my detailed video and a sample Linux Kernel module.

Weekly News Digest - Week 02 - July 2020 ↗
Wednesday' 15-Jul-2020
The Linux Channel :: Weekly News Digest - Week 02 - July 2020
> Google is teaming up with Ubuntu to bring Flutter apps to Linux
> Linux kernel developers: This new BLM coding style avoids words like blacklist
> Zstd'ing The Kernel Might See Mainline With Linux 5.9 For Faster Boot Times
> Linux 5.9 To Bring Arm Memory Tagging Extension Support
> Linux Kernel Raising Compiler Build Requirement To GCC 4.9
> Linux Developers May Discuss Allowing Rust Code Within The Kernel
> Premio Unveils Intel 9th Gen Industrial Motherboard For Advanced Embedded And IoT Solutions

CEO, CTO Talk ↗
Wednesday' 15-Jul-2020

Arduino UNO - RO Water Purifier Controller ↗
Wednesday' 15-Jul-2020
Here is a Youtube VLOG of my DIY RO Water Purifier Controller done via Arduino UNO. I want the Arduino UNO to control the RO pump, so that it pumps for a specific duration and stops automatically. This is done via Opto-isolated 4 Channel 5V 10A Relay Board meant for Arduino UNO, Raspberry Pi or similar SoC boards which offers GPIO pins. To this relay I have connected the RO water purifier booster pump which works at 24V DC connected via 220V AC to 24V DC power supply adaptar. I have also connected a small active 5V buzzer to notify the progress and completion as it fills the tank/canister.

Data-Plane and Control-Plane of a Networking Device ↗
Wednesday' 15-Jul-2020

AT&T Archives: The UNIX Operating System ↗
Wednesday' 15-Jul-2020

Socket Options - Socket Programming - setsockopt(), getsockopt() ↗
Wednesday' 15-Jul-2020

Tour of my new Home Networking Lab within VirtualBox VM ↗
Wednesday' 15-Jul-2020

Compiling a C Compiler with a C Compilter | Compile gcc with gcc ↗
Wednesday' 15-Jul-2020
The fundamental aspect of a programming language compiler is to translate code written from language to other. But most commonly compilers will compile code written in high-level human friendly language such as C, C++, Java, etc. to native CPU architecture specific (machine understandable) binary code which is nothing but sequence of CPU instructions. Hence if we see that way we should able to compile gcc Compiler source code with a gcc Compiler binary.


Trending Video:
Watch on Youtube - [138//0] 0x1f5 Smart NIC Cards - Part 3 - #TheLinuxChannel #KiranKankipati #LinuxKernelNetworking ↗

CYRIL ING√ČNIERIE - CoreFreq Linux CPU monitoring software ↗
Wednesday' 15-Jul-2020



Recommended Video:
Watch on Youtube - [153//0] 0x1ed Smart NIC Cards - Part 2 - #TheLinuxChannel #KiranKankipati #LinuxKernelNetworking ↗