Skip to content

Instantly share code, notes, and snippets.

View pietroborrello's full-sized avatar

Pietro Borrello pietroborrello

View GitHub Profile
@sam4k
sam4k / kmem_cache_alignment.md
Last active January 11, 2023 13:42
Kmem Cache Alignment

Kmem Cache Alignment

Understanding alignment, object size and objects per cache for special purposes caches in the SLUB allocator.

Overview

Let's take a look a filp, the special purpose cache for struct file, as an example.

Note: I'm using a 5.4 kernel as that's what I had on hand (newer kernels have like struct slab overlay and stuff)

Additional edit: I've simplified things here, focusing on filp, e.g. additional alignment on size and stuff can happen in calculate_sizes(), typically this is just aligning the size to word boundary (??)

@Jinmo
Jinmo / jni_all.h
Created May 26, 2017 07:36
Useful when reversing JNI on IDA Pro
/*
* Copyright (c) 1996, 1998, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*