Skip to content

Conversation

ahmetilgin
Copy link

remove empty characters

remove empty characters
@KernelPRBot
Copy link

Hi @ahmetilgin!

Thanks for your contribution to the Linux kernel!

Linux kernel development happens on mailing lists, rather than on GitHub - this GitHub repository is a read-only mirror that isn't used for accepting contributions. So that your change can become part of Linux, please email it to us as a patch.

Sending patches isn't quite as simple as sending a pull request, but fortunately it is a well documented process.

Here's what to do:

  • Format your contribution according to kernel requirements
  • Decide who to send your contribution to
  • Set up your system to send your contribution as an email
  • Send your contribution and wait for feedback

How do I format my contribution?

The Linux kernel community is notoriously picky about how contributions are formatted and sent. Fortunately, they have documented their expectations.

Firstly, all contributions need to be formatted as patches. A patch is a plain text document showing the change you want to make to the code, and documenting why it is a good idea.

You can create patches with git format-patch.

Secondly, patches need 'commit messages', which is the human-friendly documentation explaining what the change is and why it's necessary.

Thirdly, changes have some technical requirements. There is a Linux kernel coding style, and there are licensing requirements you need to comply with.

Both of these are documented in the Submitting Patches documentation that is part of the kernel.

Note that you will almost certainly have to modify your existing git commits to satisfy these requirements. Don't worry: there are many guides on the internet for doing this.

Who do I send my contribution to?

The Linux kernel is composed of a number of subsystems. These subsystems are maintained by different people, and have different mailing lists where they discuss proposed changes.

If you don't already know what subsystem your change belongs to, the get_maintainer.pl script in the kernel source can help you.

get_maintainer.pl will take the patch or patches you created in the previous step, and tell you who is responsible for them, and what mailing lists are used. You can also take a look at the MAINTAINERS file by hand.

Make sure that your list of recipients includes a mailing list. If you can't find a more specific mailing list, then LKML - the Linux Kernel Mailing List - is the place to send your patches.

It's not usually necessary to subscribe to the mailing list before you send the patches, but if you're interested in kernel development, subscribing to a subsystem mailing list is a good idea. (At this point, you probably don't need to subscribe to LKML - it is a very high traffic list with about a thousand messages per day, which is often not useful for beginners.)

How do I send my contribution?

Use git send-email, which will ensure that your patches are formatted in the standard manner. In order to use git send-email, you'll need to configure git to use your SMTP email server.

For more information about using git send-email, look at the Git documentation or type git help send-email. There are a number of useful guides and tutorials about git send-email that can be found on the internet.

How do I get help if I'm stuck?

Firstly, don't get discouraged! There are an enormous number of resources on the internet, and many kernel developers who would like to see you succeed.

Many issues - especially about how to use certain tools - can be resolved by using your favourite internet search engine.

If you can't find an answer, there are a few places you can turn:

  • Kernel Newbies - this website contains a lot of useful resources for new kernel developers.
  • If you'd like a step-by-step, challenge-based introduction to kernel development, the Eudyptula Challenge would be an excellent start.
  • The kernel documentation - see also the Documentation directory in the kernel tree.

If you get really, really stuck, you could try the owners of this bot, @daxtens and @ajdlinux. Please be aware that we do have full-time jobs, so we are almost certainly the slowest way to get answers!

I sent my patch - now what?

You wait.

You can check that your email has been received by checking the mailing list archives for the mailing list you sent your patch to. Messages may not be received instantly, so be patient. Kernel developers are generally very busy people, so it may take a few weeks before your patch is looked at.

Then, you keep waiting. Three things may happen:

  • You might get a response to your email. Often these will be comments, which may require you to make changes to your patch, or explain why your way is the best way. You should respond to these comments, and you may need to submit another revision of your patch to address the issues raised.
  • Your patch might be merged into the subsystem tree. Code that becomes part of Linux isn't merged into the main repository straight away - it first goes into the subsystem tree, which is managed by the subsystem maintainer. It is then batched up with a number of other changes sent to Linus for inclusion. (This process is described in some detail in the kernel development process guide).
  • Your patch might be ignored completely. This happens sometimes - don't take it personally. Here's what to do:
    • Wait a bit more - patches often take several weeks to get a response; more if they were sent at a busy time.
    • Kernel developers often silently ignore patches that break the rules. Check for obvious violations of the the Submitting Patches guidelines, the style guidelines, and any other documentation you can find about your subsystem. Check that you're sending your patch to the right place.
    • Try again later. When you resend it, don't add angry commentary, as that will get your patch ignored. It might also get you silently blacklisted.

Further information

Happy hacking!

This message was posted by a bot - if you have any questions or suggestions, please talk to my owners, @ajdlinux and @daxtens, or raise an issue at https://github.com/ajdlinux/KernelPRBot.

@LauraRozier
Copy link

Also, hope you are kidding with this one.. 😅

@kylelamse
Copy link

i think this should get merged in

@kylelamse
Copy link

@ItzLevvie Don't you think it's easier to read? It's now only one line of code!

@benajaero
Copy link

@ahmetilgin The kernel is written in C. C isn't an interpreted language like JS. Instead, it is compiled. Empty characters and spaces don't affect execution speed.

That being said: It looks much more readable than the current code.

Copy link

@dadur604 dadur604 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you need help?

@rxdn
Copy link

rxdn commented Jul 22, 2017

Yes is dank agree

@jeandrek
Copy link

jeandrek commented Jul 23, 2017

@Blaze349 The Linux kernel takes soooooo long to compile. This will increase compilation speed by removing all the unnecessary whitespace the compiler has to skip over.

Copy link

@jeandrek jeandrek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everybody loves it 100% (Ok I'm sorry for saying that)

Copy link

@benajaero benajaero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jonathan50 is right. This code definitely very fast. But it can be improved. There is an empty line between the includes and code. Please fix

Copy link

@benajaero benajaero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect. Almost. All the comments should be on one line to increase speed.

@ghost
Copy link

ghost commented Jul 23, 2017

@kylelamse Are you joking? Minifying a code doesn't make it 'readable'... In Javascript it's used to reduce bandwidth between server & the user, reduce page execution time & reduce file size

@ahmetilgin don't bother wasting your time on the PR. This won't improve anything except for decreasing file size. Also, there are a lot of comments in the 'minified code' that you've not bothered to remove. But again don't bother about it.

@Jonathan50 If a Linux kernel takes 'soo long to compile' then you need to invest in a better CPU like Xeon. Compiling Android or a kernel requires you to have more cores to speed up the compiling process. If you have less cores then it will take more time to compile.

No one loves the code unless it's a sarcasm

@ItzLevvie I do have to agree, this won't get accepted anyways because of contributing guidelines. So you don't have to worry about it.

@dadur604 no he doesn't need any help.. he's just trying to make the community laugh by committing garbage code.

@Blaze349 C is already fast enough... there's no need to do all the stuff the compiler will do it for you automatically or you can add some flags to optimise it.

@thibmo I believe he's trying to make the community laugh. If it's serious then I would obliviously laugh even more.

@benajaero
Copy link

@7bf70ec5 Linus Torvalds uses a Macbook Air so...yeah. Also, the kernel isn't written in C# 🤣 . It's written in C and a little Assembly.

@kylelamse
Copy link

@DizAzTor Should be easier. You no longer have to scroll through thousands of lines of code. Having it on one line just makes sense.

@jpitchardu
Copy link

Wow, now that's some beautiful code aesthetics. Congrats

@rxdn
Copy link

rxdn commented Jul 24, 2017

@DizAzTor why maintain when you can not maintain

@iamsubhranil
Copy link

Are you seriously kidding me?😂

@ghost
Copy link

ghost commented Jul 25, 2017

yes this is beautiful 10/10

@kylelamse
Copy link

No one loves the code unless it's a sarcasm

@7bf70ec5

@dschwartz783
Copy link

dschwartz783 commented Jul 26, 2017

I've never laughed at code so hard in my life. Thanks for that! Definitely a much needed contribution. Linus has nothing on this guy.

Perhaps this should go into a new Linux for Comedy branch.

@PeterAlfonsLoch
Copy link

Thats just, thats's hmm what is it?..... It's ART :D Put it in a Museum.

@iamunknown2
Copy link

iamunknown2 commented Jul 26, 2017

10/10 best commit ever made (other than adding rm -rf / to ~/.bashrc)

@hanss314
Copy link

This made me laugh so hard. I want Linus's reaction on this now.

@vuanhson
Copy link

vuanhson commented Jul 27, 2017

Linus will say "f**k you" like when he told Nvidia ✌️

@numbqq
Copy link
Contributor

numbqq commented Jul 28, 2017

Good job!

Copy link

@ryoung9550 ryoung9550 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs to be structured a bit better.

@m0x23
Copy link

m0x23 commented Jul 30, 2017

🍌

Copy link

@tilda tilda left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 Good commit

I'd really like to see @torvalds reacting to this 🤣

Copy link

@Git21221 Git21221 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finally a PR with no bug

@tushgaurav
Copy link

waiting for the pr to be merged

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Feb 28, 2025
Many filesystems such as NFS and Ceph do not implement the
`invalidate_cache` method.  On those filesystems, if writing to the
cache (`NETFS_WRITE_TO_CACHE`) fails for some reason, the kernel
crashes like this:

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor instruction fetch in kernel mode
 #PF: error_code(0x0010) - not-present page
 PGD 0 P4D 0
 Oops: Oops: 0010 [#1] SMP PTI
 CPU: 9 UID: 0 PID: 3380 Comm: kworker/u193:11 Not tainted 6.13.3-cm4all1-hp torvalds#437
 Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 10/17/2018
 Workqueue: events_unbound netfs_write_collection_worker
 RIP: 0010:0x0
 Code: Unable to access opcode bytes at 0xffffffffffffffd6.
 RSP: 0018:ffff9b86e2ca7dc0 EFLAGS: 00010202
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 7fffffffffffffff
 RDX: 0000000000000001 RSI: ffff89259d576a18 RDI: ffff89259d576900
 RBP: ffff89259d5769b0 R08: ffff9b86e2ca7d28 R09: 0000000000000002
 R10: ffff89258ceaca80 R11: 0000000000000001 R12: 0000000000000020
 R13: ffff893d158b9338 R14: ffff89259d576900 R15: ffff89259d5769b0
 FS:  0000000000000000(0000) GS:ffff893c9fa40000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: ffffffffffffffd6 CR3: 000000054442e003 CR4: 00000000001706f0
 Call Trace:
  <TASK>
  ? __die+0x1f/0x60
  ? page_fault_oops+0x15c/0x460
  ? try_to_wake_up+0x2d2/0x530
  ? exc_page_fault+0x5e/0x100
  ? asm_exc_page_fault+0x22/0x30
  netfs_write_collection_worker+0xe9f/0x12b0
  ? xs_poll_check_readable+0x3f/0x80
  ? xs_stream_data_receive_workfn+0x8d/0x110
  process_one_work+0x134/0x2d0
  worker_thread+0x299/0x3a0
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xba/0xe0
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x30/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
 Modules linked in:
 CR2: 0000000000000000

This patch adds the missing `NULL` check.

Fixes: 0e0f2df ("netfs: Dispatch write requests to process a writeback slice")
Fixes: 288ace2 ("netfs: New writeback implementation")
Cc: stable@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
@aamaanaa
Copy link

guys still open... when will this be merged? i want my kernel to be as fast as possible

Kaz205 pushed a commit to Kaz205/linux that referenced this pull request Mar 26, 2025
commit 344b7ef upstream.

Many filesystems such as NFS and Ceph do not implement the
`invalidate_cache` method.  On those filesystems, if writing to the
cache (`NETFS_WRITE_TO_CACHE`) fails for some reason, the kernel
crashes like this:

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor instruction fetch in kernel mode
 #PF: error_code(0x0010) - not-present page
 PGD 0 P4D 0
 Oops: Oops: 0010 [#1] SMP PTI
 CPU: 9 UID: 0 PID: 3380 Comm: kworker/u193:11 Not tainted 6.13.3-cm4all1-hp torvalds#437
 Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 10/17/2018
 Workqueue: events_unbound netfs_write_collection_worker
 RIP: 0010:0x0
 Code: Unable to access opcode bytes at 0xffffffffffffffd6.
 RSP: 0018:ffff9b86e2ca7dc0 EFLAGS: 00010202
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 7fffffffffffffff
 RDX: 0000000000000001 RSI: ffff89259d576a18 RDI: ffff89259d576900
 RBP: ffff89259d5769b0 R08: ffff9b86e2ca7d28 R09: 0000000000000002
 R10: ffff89258ceaca80 R11: 0000000000000001 R12: 0000000000000020
 R13: ffff893d158b9338 R14: ffff89259d576900 R15: ffff89259d5769b0
 FS:  0000000000000000(0000) GS:ffff893c9fa40000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: ffffffffffffffd6 CR3: 000000054442e003 CR4: 00000000001706f0
 Call Trace:
  <TASK>
  ? __die+0x1f/0x60
  ? page_fault_oops+0x15c/0x460
  ? try_to_wake_up+0x2d2/0x530
  ? exc_page_fault+0x5e/0x100
  ? asm_exc_page_fault+0x22/0x30
  netfs_write_collection_worker+0xe9f/0x12b0
  ? xs_poll_check_readable+0x3f/0x80
  ? xs_stream_data_receive_workfn+0x8d/0x110
  process_one_work+0x134/0x2d0
  worker_thread+0x299/0x3a0
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xba/0xe0
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x30/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
 Modules linked in:
 CR2: 0000000000000000

This patch adds the missing `NULL` check.

Fixes: 0e0f2df ("netfs: Dispatch write requests to process a writeback slice")
Fixes: 288ace2 ("netfs: New writeback implementation")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20250314164201.1993231-3-dhowells@redhat.com
Acked-by: "Paulo Alcantara (Red Hat)" <pc@manguebit.com>
cc: netfs@lists.linux.dev
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
intersectRaven pushed a commit to intersectRaven/linux that referenced this pull request Mar 29, 2025
commit 344b7ef upstream.

Many filesystems such as NFS and Ceph do not implement the
`invalidate_cache` method.  On those filesystems, if writing to the
cache (`NETFS_WRITE_TO_CACHE`) fails for some reason, the kernel
crashes like this:

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor instruction fetch in kernel mode
 #PF: error_code(0x0010) - not-present page
 PGD 0 P4D 0
 Oops: Oops: 0010 [#1] SMP PTI
 CPU: 9 UID: 0 PID: 3380 Comm: kworker/u193:11 Not tainted 6.13.3-cm4all1-hp torvalds#437
 Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 10/17/2018
 Workqueue: events_unbound netfs_write_collection_worker
 RIP: 0010:0x0
 Code: Unable to access opcode bytes at 0xffffffffffffffd6.
 RSP: 0018:ffff9b86e2ca7dc0 EFLAGS: 00010202
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 7fffffffffffffff
 RDX: 0000000000000001 RSI: ffff89259d576a18 RDI: ffff89259d576900
 RBP: ffff89259d5769b0 R08: ffff9b86e2ca7d28 R09: 0000000000000002
 R10: ffff89258ceaca80 R11: 0000000000000001 R12: 0000000000000020
 R13: ffff893d158b9338 R14: ffff89259d576900 R15: ffff89259d5769b0
 FS:  0000000000000000(0000) GS:ffff893c9fa40000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: ffffffffffffffd6 CR3: 000000054442e003 CR4: 00000000001706f0
 Call Trace:
  <TASK>
  ? __die+0x1f/0x60
  ? page_fault_oops+0x15c/0x460
  ? try_to_wake_up+0x2d2/0x530
  ? exc_page_fault+0x5e/0x100
  ? asm_exc_page_fault+0x22/0x30
  netfs_write_collection_worker+0xe9f/0x12b0
  ? xs_poll_check_readable+0x3f/0x80
  ? xs_stream_data_receive_workfn+0x8d/0x110
  process_one_work+0x134/0x2d0
  worker_thread+0x299/0x3a0
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xba/0xe0
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x30/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
 Modules linked in:
 CR2: 0000000000000000

This patch adds the missing `NULL` check.

Fixes: 0e0f2df ("netfs: Dispatch write requests to process a writeback slice")
Fixes: 288ace2 ("netfs: New writeback implementation")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20250314164201.1993231-3-dhowells@redhat.com
Acked-by: "Paulo Alcantara (Red Hat)" <pc@manguebit.com>
cc: netfs@lists.linux.dev
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
@LowLevelCodingCH
Copy link

lgtm

Copy link

@LowLevelCodingCH LowLevelCodingCH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

snajpa pushed a commit to vpsfreecz/linux that referenced this pull request Mar 29, 2025
commit 344b7ef upstream.

Many filesystems such as NFS and Ceph do not implement the
`invalidate_cache` method.  On those filesystems, if writing to the
cache (`NETFS_WRITE_TO_CACHE`) fails for some reason, the kernel
crashes like this:

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor instruction fetch in kernel mode
 #PF: error_code(0x0010) - not-present page
 PGD 0 P4D 0
 Oops: Oops: 0010 [#1] SMP PTI
 CPU: 9 UID: 0 PID: 3380 Comm: kworker/u193:11 Not tainted 6.13.3-cm4all1-hp torvalds#437
 Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 10/17/2018
 Workqueue: events_unbound netfs_write_collection_worker
 RIP: 0010:0x0
 Code: Unable to access opcode bytes at 0xffffffffffffffd6.
 RSP: 0018:ffff9b86e2ca7dc0 EFLAGS: 00010202
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 7fffffffffffffff
 RDX: 0000000000000001 RSI: ffff89259d576a18 RDI: ffff89259d576900
 RBP: ffff89259d5769b0 R08: ffff9b86e2ca7d28 R09: 0000000000000002
 R10: ffff89258ceaca80 R11: 0000000000000001 R12: 0000000000000020
 R13: ffff893d158b9338 R14: ffff89259d576900 R15: ffff89259d5769b0
 FS:  0000000000000000(0000) GS:ffff893c9fa40000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: ffffffffffffffd6 CR3: 000000054442e003 CR4: 00000000001706f0
 Call Trace:
  <TASK>
  ? __die+0x1f/0x60
  ? page_fault_oops+0x15c/0x460
  ? try_to_wake_up+0x2d2/0x530
  ? exc_page_fault+0x5e/0x100
  ? asm_exc_page_fault+0x22/0x30
  netfs_write_collection_worker+0xe9f/0x12b0
  ? xs_poll_check_readable+0x3f/0x80
  ? xs_stream_data_receive_workfn+0x8d/0x110
  process_one_work+0x134/0x2d0
  worker_thread+0x299/0x3a0
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xba/0xe0
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x30/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
 Modules linked in:
 CR2: 0000000000000000

This patch adds the missing `NULL` check.

Fixes: 0e0f2df ("netfs: Dispatch write requests to process a writeback slice")
Fixes: 288ace2 ("netfs: New writeback implementation")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20250314164201.1993231-3-dhowells@redhat.com
Acked-by: "Paulo Alcantara (Red Hat)" <pc@manguebit.com>
cc: netfs@lists.linux.dev
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Copy link

@AkemiKami201 AkemiKami201 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

omg empty characters jsjsjjsjs

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Apr 29, 2025
In this test case, we intentionally reject THP allocations via
madvise(MADV_HUGEPAGE) when THP is configured in either 'madvise' or
'always' mode. To prevent spurious failures (e.g., due to insufficient
memory for THP allocation), we deliberately omit testing the THP allocation
path when the system is configured with THP 'never' mode.

The result is as follows,

  $ ./test_progs --name="thp_adjust"
  torvalds#437     thp_adjust:OK
  Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED

CONFIG_TRANSPARENT_HUGEPAGE=y is required for this test.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
Copy link

@manig1729 manig1729 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How is this not merged yet?

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request May 20, 2025
This test case uses a BPF program to enforce the following THP allocation
policy:
- Only the current task is permitted to allocate THP.
- All other tasks are denied.

The expected behavior:
- Before the BPF prog is attached
  No tasks can allocate THP.
- After the BPF prog is attached
  Only the current task can allocate THP.
- Switch to "never" mode after the BPF prog is attached
  THP allocation is not allowed even for the current task.

The result is as follows,
  $ ./test_progs --name="thp_adjust"
  torvalds#437     thp_adjust:OK
  Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED

CONFIG_TRANSPARENT_HUGEPAGE=y is required for this test.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
@edouard-sn
Copy link

someone finally knows how to code efficiently, thank you...

#include <asm/io.h>
#include <asm/bugs.h>
#include <asm/setup.h>
#include <asm/sections.h>
#include <asm/cacheflush.h>

staticintkernel_init(void*);externvoidinit_IRQ(void);externvoidfork_init(void);externvoidradix_tree_init(void);/**Debughelper:viathisflagweknowthatwearein'earlybootupcode'*whereonlythebootprocessorisrunningwithIRQdisabled.Thismeans*twothings-IRQmustnotbeenabledbeforetheflagisclearedandsome*operationswhicharenotallowedwithIRQdisabledareallowedwhilethe*flagisset.*/boolearly_boot_irqs_disabled__read_mostly;enumsystem_statessystem_state__read_mostly;EXPORT_SYMBOL(system_state);/**Bootcommand-linearguments*/#defineMAX_INIT_ARGSCONFIG_INIT_ENV_ARG_LIMIT#defineMAX_INIT_ENVSCONFIG_INIT_ENV_ARG_LIMITexternvoidtime_init(void);/*DefaultlatetimeinitisNULL.archscanoverridethislater.*/void(*__initdatalate_time_init)(void);/*Untouchedcommandlinesavedbyarch-specificcode.*/char__initdataboot_command_line[COMMAND_LINE_SIZE];/*Untouchedsavedcommandline(eg.for/proc)*/char*saved_command_line;/*Commandlineforparameterparsing*/staticchar*static_command_line;/*Commandlineforper-initcallparameterparsing*/staticchar*initcall_command_line;staticchar*execute_command;staticchar*ramdisk_execute_command;/**Usedtogeneratewarningsifstatic_keymanipulationfunctionsareused*beforejump_label_initiscalled.*/boolstatic_key_initialized__read_mostly;EXPORT_SYMBOL_GPL(static_key_initialized);/**Ifset,thisisanindicationtothedriversthatresettheunderlying*devicebeforegoingaheadwiththeinitializationotherwisedrivermight*relyontheBIOSandskiptheresetoperation.**Thisisusefulifkernelisbootinginanunreliableenvironment.*Forex.kdumpsituationwherepreviouskernelhascrashed,BIOShasbeen*skippedanddeviceswillbeinunknownstate.*/unsignedintreset_devices;EXPORT_SYMBOL(reset_devices);staticint__initset_reset_devices(char*str){reset_devices=1;return1;}__setup("reset_devices",set_reset_devices);staticconstchar*argv_init[MAX_INIT_ARGS+2]={"init",NULL,};constchar*envp_init[MAX_INIT_ENVS+2]={"HOME=/","TERM=linux",NULL,};staticconstchar*panic_later,*panic_param;externconststructobs_kernel_param__setup_start[],__setup_end[];staticbool__initobsolete_checksetup(char*line){conststructobs_kernel_param*p;boolhad_early_param=false;p=__setup_start;do{intn=strlen(p->str);if(parameqn(line,p->str,n)){if(p->early){/*Alreadydoneinparse_early_param?*(Needsexactmatchonparampart).*Keepiterating,aswecanhaveearly*paramsand__setupsofsamenames8(*/if(line[n]=='\0'||line[n]=='=')had_early_param=true;}elseif(!p->setup_func){pr_warn("Parameter%sisobsolete,ignored\n",p->str);returntrue;}elseif(p->setup_func(line+n))returntrue;}p++;}while(p<__setup_end);returnhad_early_param;}/**Thisshouldbeapprox2Bo*oMipstostart(noteinitialshift),andwill*stillworkevenifinitiallytoolarge,itwilljusttakeslightlylonger*/unsignedlongloops_per_jiffy=(1<<12);EXPORT_SYMBOL(loops_per_jiffy);staticint__initdebug_kernel(char*str){console_loglevel=CONSOLE_LOGLEVEL_DEBUG;return0;}staticint__initquiet_kernel(char*str){console_loglevel=CONSOLE_LOGLEVEL_QUIET;return0;}early_param("debug",debug_kernel);early_param("quiet",quiet_kernel);staticint__initloglevel(char*str){intnewlevel;/**Onlyupdateloglevelvaluewhenacorrectsettingwaspassed,*topreventblindcrashes(whenloglevelbeingsetto0)that*arequitehardtodebug*/if(get_option(&str,&newlevel)){console_loglevel=newlevel;return0;}return-EINVAL;}early_param("loglevel",loglevel);/*ChangeNULtermbackto"=",tomake"param"thewholestring.*/staticint__initrepair_env_string(char*param,char*val,constchar*unused,void*arg){if(val){/*param=valorparam="val"?*/if(val==param+strlen(param)+1)val[-1]='=';elseif(val==param+strlen(param)+2){val[-2]='=';memmove(val-1,val,strlen(val)+1);val--;}elseBUG();}return0;}/*Anythingafter--getshandedstraighttoinit.*/staticint__initset_init_arg(char*param,char*val,constchar*unused,void*arg){unsignedinti;if(panic_later)return0;repair_env_string(param,val,unused,NULL);for(i=0;argv_init[i];i++){if(i==MAX_INIT_ARGS){panic_later="init";panic_param=param;return0;}}argv_init[i]=param;return0;}/**Unknownbootoptionsgethandedtoinit,unlesstheylooklike*unusedparameters(modprobewillfindthemin/proc/cmdline).*/staticint__initunknown_bootoption(char*param,char*val,constchar*unused,void*arg){repair_env_string(param,val,unused,NULL);/*Handleobsolete-styleparameters*/if(obsolete_checksetup(param))return0;/*Unusedmoduleparameter.*/if(strchr(param,'.')&&(!val||strchr(param,'.')<val))return0;if(panic_later)return0;if(val){/*Environmentoption*/unsignedinti;for(i=0;envp_init[i];i++){if(i==MAX_INIT_ENVS){panic_later="env";panic_param=param;}if(!strncmp(param,envp_init[i],val-param))break;}envp_init[i]=param;}else{/*Commandlineoption*/unsignedinti;for(i=0;argv_init[i];i++){if(i==MAX_INIT_ARGS){panic_later="init";panic_param=param;}}argv_init[i]=param;}return0;}staticint__initinit_setup(char*str){unsignedinti;execute_command=str;/**IncaseLILOisgoingtobootuswithdefaultcommandline,*itprepends"auto"beforethewholecmdlinewhichmakes*theshellthinkitshouldexecuteascriptwithsuchname.*Soweignoreallargumentsentered_before_init=...[MJ]*/for(i=1;i<MAX_INIT_ARGS;i++)argv_init[i]=NULL;return1;}__setup("init=",init_setup);staticint__initrdinit_setup(char*str){unsignedinti;ramdisk_execute_command=str;/*See"auto"commentininit_setup*/for(i=1;i<MAX_INIT_ARGS;i++)argv_init[i]=NULL;return1;}__setup("rdinit=",rdinit_setup);#ifndefCONFIG_SMPstaticconstunsignedintsetup_max_cpus=NR_CPUS;staticinlinevoidsetup_nr_cpu_ids(void){}staticinlinevoidsmp_prepare_cpus(unsignedintmaxcpus){}#endif/**Weneedtostoretheuntouchedcommandlineforfuturereference.*Wealsoneedtostorethetouchedcommandlinesincetheparameter*parsingisperformedinplace,andweshouldallowacomponentto*storereferenceofname/valueforfuturereference.*/staticvoid__initsetup_command_line(char*command_line){saved_command_line=memblock_virt_alloc(strlen(boot_command_line)+1,0);initcall_command_line=memblock_virt_alloc(strlen(boot_command_line)+1,0);static_command_line=memblock_virt_alloc(strlen(command_line)+1,0);strcpy(saved_command_line,boot_command_line);strcpy(static_command_line,command_line);}/**Weneedtofinalizeinanon-__initfunctionorelseraceconditions*betweentherootthreadandtheinitthreadmaycausestart_kernelto*bereapedbyfree_initmembeforetherootthreadhasproceededto*cpu_idle.**gcc-3.4accidentallyinlinesthisfunction,sousenoinline.*/static__initdataDECLARE_COMPLETION(kthreadd_done);staticnoinlinevoid__refrest_init(void){structtask_struct*tsk;intpid;rcu_scheduler_starting();/**Weneedtospawninitfirstsothatitobtainspid1,however*theinittaskwillendupwantingtocreatekthreads,which,if*wescheduleitbeforewecreatekthreadd,willOOPS.*/pid=kernel_thread(kernel_init,NULL,CLONE_FS);/**PininitonthebootCPU.Taskmigrationisnotproperlyworking*untilsched_init_smp()hasbeenrun.Itwillsettheallowed*CPUsforinittothenonisolatedCPUs.*/rcu_read_lock();tsk=find_task_by_pid_ns(pid,&init_pid_ns);set_cpus_allowed_ptr(tsk,cpumask_of(smp_processor_id()));rcu_read_unlock();numa_default_policy();pid=kernel_thread(kthreadd,NULL,CLONE_FS|CLONE_FILES);rcu_read_lock();kthreadd_task=find_task_by_pid_ns(pid,&init_pid_ns);rcu_read_unlock();/**Enablemight_sleep()andsmp_processor_id()checks.*TheycannotbeenabledearlierbecausewithCONFIG_PRREMPT=y*kernel_thread()wouldtriggermight_sleep()splats.With*CONFIG_PREEMPT_VOLUNTARY=ytheinittaskmighthavescheduled*already,butit'sstuckonthekthreadd_donecompletion.*/system_state=SYSTEM_SCHEDULING;complete(&kthreadd_done);/**Thebootidlethreadmustexecuteschedule()*atleastoncetogetthingsmoving:*/init_idle_bootup_task(current);schedule_preempt_disabled();/*Callintocpu_idlewithpreemptdisabled*/cpu_startup_entry(CPUHP_ONLINE);}/*Checkforearlyparams.*/staticint__initdo_early_param(char*param,char*val,constchar*unused,void*arg){conststructobs_kernel_param*p;for(p=__setup_start;p<__setup_end;p++){if((p->early&&parameq(param,p->str))||(strcmp(param,"console")==0&&strcmp(p->str,"earlycon")==0)){if(p->setup_func(val)!=0)pr_warn("Malformedearlyoption'%s'\n",param);}}/*Weaccepteverythingatthisstage.*/return0;}void__initparse_early_options(char*cmdline){parse_args("earlyoptions",cmdline,NULL,0,0,0,NULL,do_early_param);}/*Archcodecallsthisearlyon,orifnot,justbeforeotherparsing.*/void__initparse_early_param(void){staticintdone__initdata;staticchartmp_cmdline[COMMAND_LINE_SIZE]__initdata;if(done)return;/*Allfallthroughtodo_early_param.*/strlcpy(tmp_cmdline,boot_command_line,COMMAND_LINE_SIZE);parse_early_options(tmp_cmdline);done=1;}void__init__weakarch_post_acpi_subsys_init(void){}void__init__weaksmp_setup_processor_id(void){}#ifTHREAD_SIZE>=PAGE_SIZEvoid__init__weakthread_stack_cache_init(void){}#endif/**Setupkernelmemoryallocators*/staticvoid__initmm_init(void){/**page_extrequirescontiguouspages,*biggerthanMAX_ORDERunlessSPARSEMEM.*/page_ext_init_flatmem();mem_init();kmem_cache_init();percpu_init_late();pgtable_init();vmalloc_init();ioremap_huge_init();}asmlinkage__visiblevoid__initstart_kernel(void){char*command_line;char*after_dashes;set_task_stack_end_magic(&init_task);smp_setup_processor_id();debug_objects_early_init();/**SetuptheinitialcanaryASAP:*/add_latent_entropy();boot_init_stack_canary();cgroup_init_early();local_irq_disable();early_boot_irqs_disabled=true;/**Interruptsarestilldisabled.Donecessarysetups,then*enablethem.*/boot_cpu_init();page_address_init();pr_notice("%s",linux_banner);setup_arch(&command_line);mm_init_cpumask(&init_mm);setup_command_line(command_line);setup_nr_cpu_ids();setup_per_cpu_areas();boot_cpu_state_init();smp_prepare_boot_cpu();/*arch-specificboot-cpuhooks*/build_all_zonelists(NULL,NULL);page_alloc_init();pr_notice("Kernelcommandline:%s\n",boot_command_line);parse_early_param();after_dashes=parse_args("Bootingkernel",static_command_line,__start___param,__stop___param-__start___param,-1,-1,NULL,&unknown_bootoption);if(!IS_ERR_OR_NULL(after_dashes))parse_args("Settinginitargs",after_dashes,NULL,0,-1,-1,NULL,set_init_arg);jump_label_init();/**Theseuselargebootmemallocationsandmustprecede*kmem_cache_init()*/setup_log_buf(0);pidhash_init();vfs_caches_init_early();sort_main_extable();trap_init();mm_init();ftrace_init();/*trace_printkcanbeenabledhere*/early_trace_init();/**Setuptheschedulerpriorstartinganyinterrupts(suchasthe*timerinterrupt).Fulltopologysetuphappensatsmp_init()*time-butmeanwhilewestillhaveafunctioningscheduler.*/sched_init();/**Disablepreemption-earlybootupschedulingisextremely*fragileuntilwecpu_idle()forthefirsttime.*/preempt_disable();if(WARN(!irqs_disabled(),"Interruptswereenabled*very*early,fixingit\n"))local_irq_disable();radix_tree_init();/**Allowworkqueuecreationandworkitemqueueing/cancelling*early.Workitemexecutiondependsonkthreadsandstartsafter*workqueue_init().*/workqueue_init_early();rcu_init();/*Traceeventsareavailableafterthis*/trace_init();context_tracking_init();/*initsomelinksbeforeinit_ISA_irqs()*/early_irq_init();init_IRQ();tick_init();rcu_init_nohz();init_timers();hrtimers_init();softirq_init();timekeeping_init();time_init();sched_clock_postinit();printk_safe_init();perf_event_init();profile_init();call_function_init();WARN(!irqs_disabled(),"Interruptswereenabledearly\n");early_boot_irqs_disabled=false;local_irq_enable();kmem_cache_init_late();/**HACKALERT!Thisisearly.We'reenablingtheconsolebefore*we'vedonePCIsetupsetc,andconsole_init()mustbeawareof*this.Butwedowantoutputearly,incasesomethinggoeswrong.*/console_init();if(panic_later)panic("Toomanyboot%svarsat`%s'",panic_later,panic_param);lockdep_info();/**Needtorunthiswhenirqsareenabled,becauseitwants*toself-test[hard/soft]-irqson/offlockinversionbugs*too:*/locking_selftest();#ifdefCONFIG_BLK_DEV_INITRDif(initrd_start&&!initrd_below_start_ok&&page_to_pfn(virt_to_page((void*)initrd_start))<min_low_pfn){pr_crit("initrdoverwritten(0x%08lx<0x%08lx)-disablingit.\n",page_to_pfn(virt_to_page((void*)initrd_start)),min_low_pfn);initrd_start=0;}#endifpage_ext_init();debug_objects_mem_init();kmemleak_init();setup_per_cpu_pageset();numa_policy_init();if(late_time_init)late_time_init();calibrate_delay();pidmap_init();anon_vma_init();acpi_early_init();#ifdefCONFIG_X86if(efi_enabled(EFI_RUNTIME_SERVICES))efi_enter_virtual_mode();#endif#ifdefCONFIG_X86_ESPFIX64/*Shouldberunbeforethefirstnon-initthreadiscreated*/init_espfix_bsp();#endifthread_stack_cache_init();cred_init();fork_init();proc_caches_init();buffer_init();key_init();security_init();dbg_late_init();vfs_caches_init();pagecache_init();signals_init();proc_root_init();nsfs_init();cpuset_init();cgroup_init();taskstats_init_early();delayacct_init();check_bugs();acpi_subsystem_init();arch_post_acpi_subsys_init();sfi_init_late();if(efi_enabled(EFI_RUNTIME_SERVICES)){efi_free_boot_services();}/*Dotherestnon-__init'ed,we'renowalive*/rest_init();}/*Callallconstructorfunctionslinkedintothekernel.*/staticvoid__initdo_ctors(void){#ifdefCONFIG_CONSTRUCTORSctor_fn_t*fn=(ctor_fn_t*)__ctors_start;for(;fn<(ctor_fn_t*)__ctors_end;fn++)(*fn)();#endif}boolinitcall_debug;core_param(initcall_debug,initcall_debug,bool,0644);#ifdefCONFIG_KALLSYMSstructblacklist_entry{structlist_headnext;char*buf;};static__initdata_or_moduleLIST_HEAD(blacklisted_initcalls);staticint__initinitcall_blacklist(char*str){char*str_entry;structblacklist_entry*entry;/*strargumentisacomma-separatedlistoffunctions*/do{str_entry=strsep(&str,",");if(str_entry){pr_debug("blacklistinginitcall%s\n",str_entry);entry=alloc_bootmem(sizeof(*entry));entry->buf=alloc_bootmem(strlen(str_entry)+1);strcpy(entry->buf,str_entry);list_add(&entry->next,&blacklisted_initcalls);}}while(str_entry);return0;}staticbool__init_or_moduleinitcall_blacklisted(initcall_tfn){structblacklist_entry*entry;charfn_name[KSYM_SYMBOL_LEN];unsignedlongaddr;if(list_empty(&blacklisted_initcalls))returnfalse;addr=(unsignedlong)dereference_function_descriptor(fn);sprint_symbol_no_offset(fn_name,addr);/**fnwillbe"function_name[module_name]"where[module_name]isnot*displayedforbuilt-ininitfunctions.Stripoffthe[module_name].*/strreplace(fn_name,'','\0');list_for_each_entry(entry,&blacklisted_initcalls,next){if(!strcmp(fn_name,entry->buf)){pr_debug("initcall%sblacklisted\n",fn_name);returntrue;}}returnfalse;}#elsestaticint__initinitcall_blacklist(char*str){pr_warn("initcall_blacklistrequiresCONFIG_KALLSYMS\n");return0;}staticbool__init_or_moduleinitcall_blacklisted(initcall_tfn){returnfalse;}#endif__setup("initcall_blacklist=",initcall_blacklist);staticint__init_or_moduledo_one_initcall_debug(initcall_tfn){ktime_tcalltime,delta,rettime;unsignedlonglongduration;intret;printk(KERN_DEBUG"calling%pF@%i\n",fn,task_pid_nr(current));calltime=ktime_get();ret=fn();rettime=ktime_get();delta=ktime_sub(rettime,calltime);duration=(unsignedlonglong)ktime_to_ns(delta)>>10;printk(KERN_DEBUG"initcall%pFreturned%dafter%lldusecs\n",fn,ret,duration);returnret;}int__init_or_moduledo_one_initcall(initcall_tfn){intcount=preempt_count();intret;charmsgbuf[64];if(initcall_blacklisted(fn))return-EPERM;if(initcall_debug)ret=do_one_initcall_debug(fn);elseret=fn();msgbuf[0]=0;if(preempt_count()!=count){sprintf(msgbuf,"preemptionimbalance");preempt_count_set(count);}if(irqs_disabled()){strlcat(msgbuf,"disabledinterrupts",sizeof(msgbuf));local_irq_enable();}WARN(msgbuf[0],"initcall%pFreturnedwith%s\n",fn,msgbuf);add_latent_entropy();returnret;}externinitcall_t__initcall_start[];externinitcall_t__initcall0_start[];externinitcall_t__initcall1_start[];externinitcall_t__initcall2_start[];externinitcall_t__initcall3_start[];externinitcall_t__initcall4_start[];externinitcall_t__initcall5_start[];externinitcall_t__initcall6_start[];externinitcall_t__initcall7_start[];externinitcall_t__initcall_end[];staticinitcall_t*initcall_levels[]__initdata={__initcall0_start,__initcall1_start,__initcall2_start,__initcall3_start,__initcall4_start,__initcall5_start,__initcall6_start,__initcall7_start,__initcall_end,};/*Keeptheseinsyncwithinitcallsininclude/linux/init.h*/staticchar*initcall_level_names[]__initdata={"early","core","postcore","arch","subsys","fs","device","late",};staticvoid__initdo_initcall_level(intlevel){initcall_t*fn;strcpy(initcall_command_line,saved_command_line);parse_args(initcall_level_names[level],initcall_command_line,__start___param,__stop___param-__start___param,level,level,NULL,&repair_env_string);for(fn=initcall_levels[level];fn<initcall_levels[level+1];fn++)do_one_initcall(*fn);}staticvoid__initdo_initcalls(void){intlevel;for(level=0;level<ARRAY_SIZE(initcall_levels)-1;level++)do_initcall_level(level);}/**Ok,themachineisnowinitialized.Noneofthedevices*havebeentouchedyet,buttheCPUsubsystemisupand*running,andmemoryandprocessmanagementworks.**Nowwecanfinallystartdoingsomerealwork..*/staticvoid__initdo_basic_setup(void){cpuset_init_smp();shmem_init();driver_init();init_irq_proc();do_ctors();usermodehelper_enable();do_initcalls();}staticvoid__initdo_pre_smp_initcalls(void){initcall_t*fn;for(fn=__initcall_start;fn<__initcall0_start;fn++)do_one_initcall(*fn);}/**Thisfunctionrequestsmoduleswhichshouldbeloadedbydefaultandis*calledtwicerightafterinitrdismountedandrightbeforeinitis*exec'd.Ifsuchmodulesareoneitherinitrdorrootfs,theywillbe*loadedbeforecontrolispassedtouserland.*/void__initload_default_modules(void){load_default_elevator_module();}staticintrun_init_process(constchar*init_filename){argv_init[0]=init_filename;returndo_execve(getname_kernel(init_filename),(constchar__user*const__user*)argv_init,(constchar__user*const__user*)envp_init);}staticinttry_to_run_init_process(constchar*init_filename){intret;ret=run_init_process(init_filename);if(ret&&ret!=-ENOENT){pr_err("Startinginit:%sexistsbutcouldn'texecuteit(error%d)\n",init_filename,ret);}returnret;}staticnoinlinevoid__initkernel_init_freeable(void);#ifdefined(CONFIG_STRICT_KERNEL_RWX)||defined(CONFIG_STRICT_MODULE_RWX)boolrodata_enabled__ro_after_init=true;staticint__initset_debug_rodata(char*str){returnstrtobool(str,&rodata_enabled);}__setup("rodata=",set_debug_rodata);#endif#ifdefCONFIG_STRICT_KERNEL_RWXstaticvoidmark_readonly(void){if(rodata_enabled){mark_rodata_ro();rodata_test();}elsepr_info("Kernelmemoryprotectiondisabled.\n");}#elsestaticinlinevoidmark_readonly(void){pr_warn("Thisarchitecturedoesnothavekernelmemoryprotection.\n");}#endifstaticint__refkernel_init(void*unused){intret;kernel_init_freeable();/*needtofinishallasync__initcodebeforefreeingthememory*/async_synchronize_full();ftrace_free_init_mem();free_initmem();mark_readonly();system_state=SYSTEM_RUNNING;numa_default_policy();rcu_end_inkernel_boot();if(ramdisk_execute_command){ret=run_init_process(ramdisk_execute_command);if(!ret)return0;pr_err("Failedtoexecute%s(error%d)\n",ramdisk_execute_command,ret);}/**Wetryeachoftheseuntilonesucceeds.**TheBourneshellcanbeusedinsteadofinitifweare*tryingtorecoverareallybrokenmachine.*/if(execute_command){ret=run_init_process(execute_command);if(!ret)return0;panic("Requestedinit%sfailed(error%d).",execute_command,ret);}if(!try_to_run_init_process("/sbin/init")||!try_to_run_init_process("/etc/init")||!try_to_run_init_process("/bin/init")||!try_to_run_init_process("/bin/sh"))return0;panic("Noworkinginitfound.Trypassinginit=optiontokernel.""SeeLinuxDocumentation/admin-guide/init.rstforguidance.");}staticnoinlinevoid__initkernel_init_freeable(void){/**Waituntilkthreaddisallset-up.*/wait_for_completion(&kthreadd_done);/*Nowtheschedulerisfullysetupandcandoblockingallocations*/gfp_allowed_mask=__GFP_BITS_MASK;/**initcanallocatepagesonanynode*/set_mems_allowed(node_states[N_MEMORY]);cad_pid=task_pid(current);smp_prepare_cpus(setup_max_cpus);workqueue_init();init_mm_internals();do_pre_smp_initcalls();lockup_detector_init();smp_init();sched_init_smp();page_alloc_init_late();do_basic_setup();/*Openthe/dev/consoleontherootfs,thisshouldneverfail*/if(sys_open((constchar__user*)"/dev/console",O_RDWR,0)<0)pr_err("Warning:unabletoopenaninitialconsole.\n");(void)sys_dup(0);(void)sys_dup(0);/**checkifthereisanearlyuserspaceinit.Ifyes,letitdoall*thework*/if(!ramdisk_execute_command)ramdisk_execute_command="/init";if(sys_access((constchar__user*)ramdisk_execute_command,0)!=0){ramdisk_execute_command=NULL;prepare_namespace();}/**Ok,wehavecompletedtheinitialbootup,and*we'reessentiallyupandrunning.Getridofthe*initmemsegmentsandstarttheuser-modestuff..**rootfsisavailablenow,tryloadingthepublickeys*anddefaultmodules*/integrity_load_keys();load_default_modules();}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is beautiful

intel-lab-lkp pushed a commit to intel-lab-lkp/linux that referenced this pull request Jun 8, 2025
This test case uses a BPF program to enforce the following THP allocation
policy:
- Current task will wakeup khugepaged to allocate THP

The result is as follows,
  $ ./test_progs --name="thp_adjust"
  torvalds#437     thp_adjust:OK
  Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED

CONFIG_TRANSPARENT_HUGEPAGE=y is required for this test.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
ldts pushed a commit to ldts/linux that referenced this pull request Jun 11, 2025
Many filesystems such as NFS and Ceph do not implement the
`invalidate_cache` method.  On those filesystems, if writing to the
cache (`NETFS_WRITE_TO_CACHE`) fails for some reason, the kernel
crashes like this:

 BUG: kernel NULL pointer dereference, address: 0000000000000000
 #PF: supervisor instruction fetch in kernel mode
 #PF: error_code(0x0010) - not-present page
 PGD 0 P4D 0
 Oops: Oops: 0010 [#1] SMP PTI
 CPU: 9 UID: 0 PID: 3380 Comm: kworker/u193:11 Not tainted 6.13.3-cm4all1-hp torvalds#437
 Hardware name: HP ProLiant DL380 Gen9/ProLiant DL380 Gen9, BIOS P89 10/17/2018
 Workqueue: events_unbound netfs_write_collection_worker
 RIP: 0010:0x0
 Code: Unable to access opcode bytes at 0xffffffffffffffd6.
 RSP: 0018:ffff9b86e2ca7dc0 EFLAGS: 00010202
 RAX: 0000000000000000 RBX: 0000000000000000 RCX: 7fffffffffffffff
 RDX: 0000000000000001 RSI: ffff89259d576a18 RDI: ffff89259d576900
 RBP: ffff89259d5769b0 R08: ffff9b86e2ca7d28 R09: 0000000000000002
 R10: ffff89258ceaca80 R11: 0000000000000001 R12: 0000000000000020
 R13: ffff893d158b9338 R14: ffff89259d576900 R15: ffff89259d5769b0
 FS:  0000000000000000(0000) GS:ffff893c9fa40000(0000) knlGS:0000000000000000
 CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
 CR2: ffffffffffffffd6 CR3: 000000054442e003 CR4: 00000000001706f0
 Call Trace:
  <TASK>
  ? __die+0x1f/0x60
  ? page_fault_oops+0x15c/0x460
  ? try_to_wake_up+0x2d2/0x530
  ? exc_page_fault+0x5e/0x100
  ? asm_exc_page_fault+0x22/0x30
  netfs_write_collection_worker+0xe9f/0x12b0
  ? xs_poll_check_readable+0x3f/0x80
  ? xs_stream_data_receive_workfn+0x8d/0x110
  process_one_work+0x134/0x2d0
  worker_thread+0x299/0x3a0
  ? __pfx_worker_thread+0x10/0x10
  kthread+0xba/0xe0
  ? __pfx_kthread+0x10/0x10
  ret_from_fork+0x30/0x50
  ? __pfx_kthread+0x10/0x10
  ret_from_fork_asm+0x1a/0x30
  </TASK>
 Modules linked in:
 CR2: 0000000000000000

This patch adds the missing `NULL` check.

Fixes: 0e0f2df ("netfs: Dispatch write requests to process a writeback slice")
Fixes: 288ace2 ("netfs: New writeback implementation")
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://lore.kernel.org/r/20250314164201.1993231-3-dhowells@redhat.com
Acked-by: "Paulo Alcantara (Red Hat)" <pc@manguebit.com>
cc: netfs@lists.linux.dev
cc: linux-cifs@vger.kernel.org
cc: linux-fsdevel@vger.kernel.org
cc: stable@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
@Meat-Rack
Copy link

Make it use only booleans and unsigned integers.
Efficient code and only be done when you cut the memory inefficient data types like signed integers, strings and god forbid, arrays.

Copy link

@LowLevelCodingCH LowLevelCodingCH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All dependencies should be implicitly declared, without includes nor bodyless-functions,
or bodyless-functions must be put infront of the line,

int printf(char*,...);

and so on. Otherwise, unacceptable.
ONE LINE.

@bomberfish
Copy link

LGTM 👍

1 similar comment
@demif1end
Copy link

LGTM 👍

@Approxamatrix
Copy link

This is so peak. We should defo let it go through XD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.