Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

this code very fast #437

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

this code very fast #437

wants to merge 2 commits into from

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 🤣

@alldiezzz
Copy link

It's take so Long journey to reach bottom 🤣.

chewitt pushed a commit to chewitt/linux that referenced this pull request Dec 2, 2019
[ Upstream commit 86968ef ]

Calling ceph_buffer_put() in __ceph_setxattr() may end up freeing the
i_xattrs.prealloc_blob buffer while holding the i_ceph_lock.  This can be
fixed by postponing the call until later, when the lock is released.

The following backtrace was triggered by fstests generic/117.

  BUG: sleeping function called from invalid context at mm/vmalloc.c:2283
  in_atomic(): 1, irqs_disabled(): 0, pid: 650, name: fsstress
  3 locks held by fsstress/650:
   #0: 00000000870a0fe8 (sb_writers#8){.+.+}, at: mnt_want_write+0x20/0x50
   #1: 00000000ba0c4c74 (&type->i_mutex_dir_key#6){++++}, at: vfs_setxattr+0x55/0xa0
   #2: 000000008dfbb3f2 (&(&ci->i_ceph_lock)->rlock){+.+.}, at: __ceph_setxattr+0x297/0x810
  CPU: 1 PID: 650 Comm: fsstress Not tainted 5.2.0+ torvalds#437
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58-prebuilt.qemu.org 04/01/2014
  Call Trace:
   dump_stack+0x67/0x90
   ___might_sleep.cold+0x9f/0xb1
   vfree+0x4b/0x60
   ceph_buffer_release+0x1b/0x60
   __ceph_setxattr+0x2b4/0x810
   __vfs_setxattr+0x66/0x80
   __vfs_setxattr_noperm+0x59/0xf0
   vfs_setxattr+0x81/0xa0
   setxattr+0x115/0x230
   ? filename_lookup+0xc9/0x140
   ? rcu_read_lock_sched_held+0x74/0x80
   ? rcu_sync_lockdep_assert+0x2e/0x60
   ? __sb_start_write+0x142/0x1a0
   ? mnt_want_write+0x20/0x50
   path_setxattr+0xba/0xd0
   __x64_sys_lsetxattr+0x24/0x30
   do_syscall_64+0x50/0x1c0
   entry_SYSCALL_64_after_hwframe+0x49/0xbe
  RIP: 0033:0x7ff23514359a

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
@ChemicalRascal
Copy link

Line 94 is too long. Please consider removing it entirely.

@dodona2
Copy link

dodona2 commented Jan 24, 2020

please close this very fake thread

@revmischa
Copy link

please close this very fake thread

hlep i keep getting spam to how do i unsubscribe from linux ??

@Geolim4
Copy link

Geolim4 commented Feb 12, 2020

@pgarig please review this.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Please don't play with the Linux Kernel. The community will thank you.

Damenly pushed a commit to Damenly/linux that referenced this pull request Nov 13, 2022
[ Upstream commit 86968ef ]

Calling ceph_buffer_put() in __ceph_setxattr() may end up freeing the
i_xattrs.prealloc_blob buffer while holding the i_ceph_lock.  This can be
fixed by postponing the call until later, when the lock is released.

The following backtrace was triggered by fstests generic/117.

  BUG: sleeping function called from invalid context at mm/vmalloc.c:2283
  in_atomic(): 1, irqs_disabled(): 0, pid: 650, name: fsstress
  3 locks held by fsstress/650:
   #0: 00000000870a0fe8 (sb_writers#8){.+.+}, at: mnt_want_write+0x20/0x50
   #1: 00000000ba0c4c74 (&type->i_mutex_dir_key#6){++++}, at: vfs_setxattr+0x55/0xa0
   #2: 000000008dfbb3f2 (&(&ci->i_ceph_lock)->rlock){+.+.}, at: __ceph_setxattr+0x297/0x810
  CPU: 1 PID: 650 Comm: fsstress Not tainted 5.2.0+ torvalds#437
  Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.1-0-ga5cab58-prebuilt.qemu.org 04/01/2014
  Call Trace:
   dump_stack+0x67/0x90
   ___might_sleep.cold+0x9f/0xb1
   vfree+0x4b/0x60
   ceph_buffer_release+0x1b/0x60
   __ceph_setxattr+0x2b4/0x810
   __vfs_setxattr+0x66/0x80
   __vfs_setxattr_noperm+0x59/0xf0
   vfs_setxattr+0x81/0xa0
   setxattr+0x115/0x230
   ? filename_lookup+0xc9/0x140
   ? rcu_read_lock_sched_held+0x74/0x80
   ? rcu_sync_lockdep_assert+0x2e/0x60
   ? __sb_start_write+0x142/0x1a0
   ? mnt_want_write+0x20/0x50
   path_setxattr+0xba/0xd0
   __x64_sys_lsetxattr+0x24/0x30
   do_syscall_64+0x50/0x1c0
   entry_SYSCALL_64_after_hwframe+0x49/0xbe
  RIP: 0033:0x7ff23514359a

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
@doraemonxxx
Copy link

2024: IS THIS REAL?

@tigercoding56
Copy link

tigercoding56 commented May 15, 2024

please close this very fake thread

hlep i keep getting spam to how do i unsubscribe from linux ??

DONT OR I'll send my penguin army to put a single // in front of your linux kernel source

@tigercoding56
Copy link

the next step is to put everything in a single file.

Copy link

@VicenteOstornol VicenteOstornol left a comment

Choose a reason for hiding this comment

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

Looks good to me

Copy link

@Fukuro192 Fukuro192 left a comment

Choose a reason for hiding this comment

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

good stuff

Copy link

@y4nci y4nci left a comment

Choose a reason for hiding this comment

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

preach brother

Copy link

@erickcestari erickcestari left a comment

Choose a reason for hiding this comment

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

spaces sometime can reduce the readability. I aprove

integrity_load_keys();
load_default_modules();
}
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.

Lgtm 👍

Copy link

@GabsMarcelino GabsMarcelino left a comment

Choose a reason for hiding this comment

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

LGTM

@Vetpetmon
Copy link

Indeed, very fast for computers, but not for humans.

@jeandrek
Copy link

jeandrek commented Nov 6, 2024

@Vetpetmon Someone comments on a PR I left a satirical comment on 7.29 years ago, and it's the ATer whom I (who changed my username from Jonathan50) quarreled with about Linux vs. Windows and stuff on TIMaC almost 9 years ago? 0_o (sorry about that BTW, it's funny now)

@mvdebolskiy
Copy link

Can you resolve the conflict, please?

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

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.