Skip to content

Instantly share code, notes, and snippets.

@laoar
laoar / per memcg score_adj
Created August 22, 2019 07:13
patch for memcg socre_adj
--- a/include/linux/memcontrol.h
+++ b/include/linux/memcontrol.h
@@ -21,6 +21,7 @@
#include <linux/vmstat.h>
#include <linux/writeback.h>
#include <linux/page-flags.h>
+#include <linux/oom.h>
struct mem_cgroup;
struct page;
@laoar
laoar / cgroup-aware-slab.diff
Last active October 22, 2017 10:33
memcg-aware slab
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -145,7 +145,7 @@ static int anon_pipe_buf_steal(struct pipe_inode_info *pipe,
if (page_count(page) == 1) {
if (memcg_kmem_enabled())
- memcg_kmem_uncharge(page, 0);
+ memcg_kmem_uncharge(page, 0, NULL);
__SetPageLocked(page);
return 0;
@laoar
laoar / netns: tcp_rto_max.diff
Last active October 22, 2017 10:20
introduce a new sysctl knob sysctl_tcp_rto_max to control the max value of TCP_RTO and make it in netns
diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
index 9a14a08..f12c655 100644
--- a/include/net/netns/ipv4.h
+++ b/include/net/netns/ipv4.h
@@ -125,6 +125,7 @@ struct netns_ipv4 {
int sysctl_tcp_sack;
int sysctl_tcp_window_scaling;
int sysctl_tcp_timestamps;
+ int sysctl_tcp_rto_max;
struct inet_timewait_death_row tcp_death_row;
@laoar
laoar / mmap_zcopy
Last active June 3, 2024 09:07
an example of kernel space to user space zero-copy via mmap, and also the comparing mmap with read/write
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/init.h>
#include <linux/fs.h>
#include <linux/mm.h>
#include <asm/uaccess.h>
#define MAX_SIZE (PAGE_SIZE * 2) /* max size mmaped to userspace */
#define DEVICE_NAME "mchar"