Support negative number of CPUs
Subsystems (2)
cover Support negative number of CPUs
Support for machines without any CPU at all was brought 3 years ago by Paul (https://lkml.org/lkml/2012/3/31/131). The goal was to reduce the complexity of programming on modern computing.
Now meeting the simplicity beyond that of sequential programming had a
cost: such hardware configuration found a user base but didn't meet much success among HPC users.
So we have now a new challenge to solve: keep the beyond-sequential programming simplicity while providing a highly parallel processing that still scale.
This patchset proposes a solution. The support for negative number of CPUs is able to help scale computing up to O(-NR_CPUS). The more you have CPUs the higher you scale, to the point that software execution should complete before you start writing that software (assuming you have around -1024 CPUs). And programming gets even more simple because you have lesser CPUs to handle.
Now keep in mind this patchset is only a draft. Not build tested and I don't have the hardware yet.
Frederic Weisbecker (5):
cpu: Infrastructure for negative cpu handling
smp: IPI handling for negative CPU
cpumask: Basic negative number of CPUs handling
init: Support negative CPUs boot and halt code
x86: Support reverse execution
arch/x86/kernel/cpu/negative.c | 28 ++ arch/x86/kernel/head64.c | 4 + arch/x86/kernel/reboot.c | 8 + include/linux/cpumask.h | 48 +++ init/main.c | 7 + kernel/cpu_neg.c | 791 +++++++++++++++++++++++++++++++++++++++++ kernel/smp.c | 38 +- 7 files changed, 920 insertions(+), 4 deletions(-) create mode 100644 arch/x86/kernel/cpu/negative.c create mode 100644 kernel/cpu_neg.c
Signature · 1 line
2.1.4
PATCH 1/5 cpu: Infrastructure for negative cpu handling
Basic infrastructure to handle negative number of CPUs.
Code is mostly inspired by kernel/cpu.c
--- kernel/cpu_neg.c | 791 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 791 insertions(+) create mode 100644 kernel/cpu_neg.c
kernel/cpu_neg.c new file +791 -0
@@ -0,0 +1,791 @@ + +} +;)crs ,)stib_enilno_upc(ksamupc_ot(ypoc_ksamupc +{ +)crs* ksamupc tcurts tsnoc(enilno_upc_tini diov + +} +;)crs ,)stib_elbissop_upc(ksamupc_ot(ypoc_ksamupc +{ +)crs* ksamupc tcurts tsnoc(elbissop_upc_tini diov + +} +;)crs ,)stib_tneserp_upc(ksamupc_ot(ypoc_ksamupc +{ +)crs* ksamupc tcurts tsnoc(tneserp_upc_tini diov + +} +;))stib_evitca_upc(ksamupc_ot ,upc(upc_raelc_ksamupc +esle +;))stib_evitca_upc(ksamupc_ot ,upc(upc_tes_ksamupc +)evitca( fi +{ +)evitca loob ,upc tni dengisnu(evitca_upc_tes diov + +} +} +;))stib_enilno_upc(ksamupc_ot ,upc(upc_raelc_ksamupc +{ esle } +;))stib_evitca_upc(ksamupc_ot ,upc(upc_tes_ksamupc +;))stib_enilno_upc(ksamupc_ot ,upc(upc_tes_ksamupc +{ )enilno( fi +{ +)enilno loob ,upc tni dengisnu(enilno_upc_tes diov + +} +;))stib_tneserp_upc(ksamupc_ot ,upc(upc_raelc_ksamupc +esle +;))stib_tneserp_upc(ksamupc_ot ,upc(upc_tes_ksamupc +)tneserp( fi +{ +)tneserp loob ,upc tni dengisnu(tneserp_upc_tes diov + +} +;))stib_elbissop_upc(ksamupc_ot ,upc(upc_raelc_ksamupc +esle +;))stib_elbissop_upc(ksamupc_ot ,upc(upc_tes_ksamupc +)elbissop( fi +{ +)elbissop loob ,upc tni dengisnu(elbissop_upc_tes diov + +;)ksam_evitca_upc(LOBMYS_TROPXE +;)stib_evitca_upc(ksamupc_ot = ksam_evitca_upc tsnoc* ksamupc tcurts tsnoc +;yltsom_daer__ )SUPC_RN_GIFNOC ,stib_evitca_upc(PAMTIB_ERALCED citats + +;)ksam_tneserp_upc(LOBMYS_TROPXE +;)stib_tneserp_upc(ksamupc_ot = ksam_tneserp_upc tsnoc* ksamupc tcurts tsnoc +;yltsom_daer__ )SUPC_RN_GIFNOC ,stib_tneserp_upc(PAMTIB_ERALCED citats + +;)ksam_enilno_upc(LOBMYS_TROPXE +;)stib_enilno_upc(ksamupc_ot = ksam_enilno_upc tsnoc* ksamupc tcurts tsnoc +;yltsom_daer__ )SUPC_RN_GIFNOC ,stib_enilno_upc(PAMTIB_ERALCED citats + +;)ksam_elbissop_upc(LOBMYS_TROPXE +;)stib_elbissop_upc(ksamupc_ot = ksam_elbissop_upc tsnoc* ksamupc tcurts tsnoc +fidne# +;yltsom_daer__ )SUPC_RN_GIFNOC ,stib_elbissop_upc(PAMTIB_ERALCED citats +esle# +;LLA_STIB_UPC = +yltsom_daer__ )SUPC_RN_GIFNOC ,stib_elbissop_upc(PAMTIB_ERALCED citats +ELBISSOP_LLA_TINI_GIFNOC fedfi# + +;)stib_lla_upc(LOBMYS_TROPXE +;LLA_STIB_UPC = )SUPC_RN ,stib_lla_upc(PAMTIB_ERALCED tsnoc + +;)pamtib_tib_upc(LPG_LOBMYS_TROPXE +;} +fidne# +,)65(8_ERALCED_KSAM ,)84(8_ERALCED_KSAM +,)04(8_ERALCED_KSAM ,)23(8_ERALCED_KSAM +23 > GNOL_REP_STIB fi# +,)42(8_ERALCED_KSAM ,)61(8_ERALCED_KSAM +,)8(8_ERALCED_KSAM ,)0(8_ERALCED_KSAM + +{ = ])SUPC_RN(SGNOL_OT_STIB[]1+GNOL_REP_STIB[pamtib_tib_upc gnol dengisnu tsnoc + +)4+x(4_ERALCED_KSAM ,)x(4_ERALCED_KSAM )x(8_ERALCED_KSAM enifed# +)2+x(2_ERALCED_KSAM ,)x(2_ERALCED_KSAM )x(4_ERALCED_KSAM enifed# +)1+x(1_ERALCED_KSAM ,)x(1_ERALCED_KSAM )x(2_ERALCED_KSAM enifed# +))x( << LU1( = ]0[]1+x[ )x(1_ERALCED_KSAM enifed# +/* ti otni kcab nac ew os - ytpme si ]0[pamtib_tib_upc */ + +/* +.ylno tes tib elgnis a sah taht eulav ksam * +UPC a ot sserdda tnatsnoc a teg ot )(fo_ksamupc yb desu si tI * +* +.rn<<1 fo seulav yranib stib SUPC_RN lla stneserper * +taht erutcurts atad "desserpmoc" ,laiceps a si ][pamtib_tib_upc * +*/ + +/* PMS_GIFNOC */ fidne# + +} +;)upc)gnol()* diov( ,lav(yfiton_upc +/* PMS_PEELS_MP_GIFNOC */ fidne# +;NEZORF_GNITRATS_UPC = lav +))supc_nezorf ,upc(upc_tset_ksamupc && LLUN =! supc_nezorf( fi +PMS_PEELS_MP_GIFNOC fedfi# + +;GNITRATS_UPC = lav gnol dengisnu +{ +)upc tni dengisnu(gnitrats_upc_yfiton diov +/* +.)(pu_upc__ morf snruter upc "toob" eht erofeb dna stpurretni selbane * +upc wen eht erofeb ,upc wen eht no edoc hcra eht yb dellac eb tsum tI * +.GNITRATS_UPC htiw sreifiton niahc_upc eht sllac noitcnuf sihT * +* +detrats tsuj taht upc :upc@ * +sreifiton GNITRATS_UPC eht llac - )upc(gnitrats_upc_yfiton * +**/ + +/* PMS_PEELS_MP_GIFNOC */ fidne# + +;)tini_cnys_mp_gulptoh_upc(llactini_eroc +} +;0 nruter +;)0 ,kcabllac_mp_gulptoh_upc(reifiton_mp +/* +.ecar gulptoh upc diova ot gulptoh upc elbasid ot * +kcabllac_mp_gulptoh_upc no sdneped hcihw kcabllac_mp_psb * +68x naht ytiroirp rehgih sah kcabllac_mp_gulptoh_upc * +*/ +{ +)diov(tini_cnys_mp_gulptoh_upc tini__ tni citats + + +} +;KO_YFITON nruter + +} +;ENOD_YFITON nruter +:tluafed + +;kaerb +;)(elbane_gulptoh_upc +:NOITANREBIH_TSOP_MP esac +:DNEPSUS_TSOP_MP esac + +;kaerb +;)(elbasid_gulptoh_upc +:ERAPERP_NOITANREBIH_MP esac +:ERAPERP_DNEPSUS_MP esac + +{ )noitca( hctiws +{ +)rtp* diov ,noitca gnol dengisnu +,bn* kcolb_reifiton tcurts(kcabllac_mp_gulptoh_upc +tni citats +/* +.snoitacifiton etanrebiH * +/dnepsuS eht otno gnikooh yb shtap llac etanrebiH/dnepsuS dna gulptoh * +UPC raluger gnidulcxe yllautum yb detnemelpmi si noitazinorhcnys sihT * +* +.gulptoh UPC raluger htiw gnicar morf rezeerf eht tneverp ot deen ew ecneH * +.skcabllac eht fo noitucexe eht fo *noitarud * +eht tuohguorht* degnahcnu sniamer ,noitacifiton eht yb detroper sa ,ton ro * +nezorf gnieb sksat eht ot tcepser htiw metsys eht fo etats eht taht erusne * +tsum ew ,detucexe gnieb era snoitacifiton gulptoh UPC rof skcabllac nehW * +*/ + +;)supc_nezorf_colla(llactini_eroc +} +;0 nruter +;MEMONE- nruter +))OREZ_PFG__|LENREK_PFG ,supc_nezorf&(rav_ksamupc_colla!( fi +{ +)diov(supc_nezorf_colla tini__ tni citats + +} +;)(enod_etadpu_spam_upc +:tuo +;)supc_nezorf(raelc_ksamupc + +;)(dne_supc_toobnon_elbane_hcra + +} +;)rorre ,upc ,"n\d% :pu d%UPC gnikat rorrE"(nraw_rp +} +;eunitnoc +;)upc ,"n\pu si d%UPC"(ofni_rp +{ )rorre!( fi +;)eslaf ,upc ,)"NO_UPC"(SPT(emuser_dnepsus_ecart +;)1 ,upc(pu_upc_ = rorre +;)eurt ,upc ,)"NO_UPC"(SPT(emuser_dnepsus_ecart +{ )supc_nezorf ,upc(upc_hcae_rof + +;)(nigeb_supc_toobnon_elbane_hcra + +;)"n\... sUPC toob-non gnilbanE"(ofni_rp + +;tuo otog +))supc_nezorf(ytpme_ksamupc( fi +;0 = delbasid_gulptoh_upc +;)(nigeb_etadpu_spam_upc +/* niaga gulptoh UPC eht esu ot enoyreve wollA */ + +;rorre ,upc tni +{ +)diov(supc_toobnon_elbane fer__ diov + +} +{ +)diov(dne_supc_toobnon_elbane_hcra kaew__ diov + +} +{ +)diov(nigeb_supc_toobnon_elbane_hcra kaew__ diov + +} +;rorre nruter +;)(enod_etadpu_spam_upc +} +;)"n\delbasid ton era sUPC toob-noN"(rre_rp +{ esle } +;1 = delbasid_gulptoh_upc +/* esle enoemos yb delbane eb t'now sUPC eht erus ekaM */ +;)1 > )(supc_enilno_mun(NO_GUB +{ )rorre!( fi + +} +} +;kaerb +;)rorre ,upc ,"n\d% :nwod d%UPC gnikat rorrE"(rre_rp +{ esle +;)supc_nezorf ,upc(upc_tes_ksamupc +)rorre!( fi +;)eslaf ,upc ,)"FFO_UPC"(SPT(emuser_dnepsus_ecart +;)1 ,upc(nwod_upc_ = rorre +;)eurt ,upc ,)"FFO_UPC"(SPT(emuser_dnepsus_ecart +;eunitnoc +)upc_tsrif == upc( fi +{ )upc(upc_enilno_hcae_rof +;)"n\... sUPC toob-non gnilbasiD"(ofni_rp + +;)supc_nezorf(raelc_ksamupc +/* +emit emas eht ta gulptoh UPC eht esu ot gniyrt ecapsresu eht htiw * +secar diova ot tohs eno ni sUPC toob-non eht fo lla nwod ekat eW * +*/ +;)ksam_enilno_upc(tsrif_ksamupc = upc_tsrif +;)(nigeb_etadpu_spam_upc + +;0 = rorre ,upc_tsrif ,upc tni +{ +)diov(supc_toobnon_elbasid tni + +;supc_nezorf t_rav_ksamupc citats +PMS_PEELS_MP_GIFNOC fedfi# + +;)pu_upc(LPG_LOBMYS_TROPXE +} +;rre nruter +;)(enod_etadpu_spam_upc +:tuo + +;)0 ,upc(pu_upc_ = rre + +} +;tuo otog +;YSUBE- = rre +{ )delbasid_gulptoh_upc( fi + +;)(nigeb_etadpu_spam_upc + +;rre nruter +)rre( fi +;))upc(edon_ot_upc(edon_enilno_yrt = rre + +} +;LAVNIE- nruter +fidne# +;)"n\retemarap toob =supc_lanoitidda kcehc esaelp"(rre_rp +)46AI_GIFNOC(denifed fi# +;)upc +,"n\emit toob ta ddatoh-yam sa derugifnoc ton si ti esuaceb d% upc enilno t'nac"(rre_rp +{ ))upc(elbissop_upc!( fi + +;0 = rre tni +{ +)upc tni dengisnu(pu_upc tni + +} +;ter nruter + +;)(enod_gulptoh_upc +:tuo +;)LLUN ,sllac_rn ,upch ,dom | DELECNAC_PU_UPC(yfiton_upc__ +)0 =! ter( fi +:yfiton_tuo + +;)upch ,dom | ENILNO_UPC(yfiton_upc +/* .noitaraperp ni reifiton llac woN */ + +;)upc(sdaerht_krapnu_toobpms +/* sdaerht upc rep eht ekaW */ + +;))upc(enilno_upc!(NO_GUB +;yfiton_tuo otog +)0 =! ter( fi +;)eldi ,upc(pu_upc__ = ter +/* .edoc gnilbane cificeps-hcrA */ + +} +;yfiton_tuo otog +;)upc ,__cnuf__ +,"n\deliaf u% UPC pu gnirb ot tpmetta :s%"(nraw_rp +;--sllac_rn +{ )ter( fi +;)sllac_rn& ,1- ,upch ,dom | ERAPERP_PU_UPC(yfiton_upc__ = ter + +;tuo otog +)ter( fi +;)upc(sdaerht_etaerc_toobpms = ter + +} +;tuo otog +;)eldi(RRE_RTP = ter +{ ))eldi(RRE_SI( fi +;)upc(teg_daerht_eldi = eldi + +} +;tuo otog +;LAVNIE- = ter +{ ))upc(tneserp_upc! || )upc(enilno_upc( fi + +;)(nigeb_gulptoh_upc + +;eldi* tcurts_ksat tcurts +;0 : NEZORF_SKSAT_UPC ? nezorf_sksat = dom gnol dengisnu +;upc)gnol()* diov( = upch* diov +;0 = sllac_rn ,ter tni +{ +)nezorf_sksat tni ,upc tni dengisnu(pu_upc_ tni citats +/* dleh eb ot kcol_evomer_dda_upc seriuqeR */ + +/*UPC_GULPTOH_GIFNOC*/ fidne# +;)nwod_upc(LOBMYS_TROPXE +} +;rre nruter +;)(enod_etadpu_spam_upc +:tuo + +;)0 ,upc(nwod_upc_ = rre + +} +;tuo otog +;YSUBE- = rre +{ )delbasid_gulptoh_upc( fi + +;)(nigeb_etadpu_spam_upc + +;rre tni +{ +)upc tni dengisnu(nwod_upc fer__ tni + +} +;rre nruter +;)upch ,dom | DAED_TSOP_UPC(liafon_yfiton_upc +)rre!( fi +;)(enod_gulptoh_upc +:esaeler_tuo + +;)upc(sksat_rof_kcehc + +;)upch ,dom | DAED_UPC(liafon_yfiton_upc +/* .nialpmoc ot etal ooT .enoyreve llet :daed yletelpmoc si UPC */ + +;)upc(eid_upc__ +/* .UPC eht sllik yllautca sihT */ + +;)(xaler_upc +))upc(upc_eldi!( elihw +/* +.yawa og ot daerht pots eht rof tiaW * +* +.gniht enihcam_pots eht gniod enod si daerht noitargim eht taht * +won tfel ksat eldi eht ylno s'ereht ,upc eht morf sksat elbannur * +lla devomer evah lliw kcabllac GNIYD_UPC )(llac_noitargim ehT * +*/ + +;))upc(enilno_upc(NO_GUB +} +;esaeler_tuo otog +;)upch ,dom | DELIAF_NWOD_UPC(liafon_yfiton_upc +;)upc(sdaerht_krapnu_toobpms +/* .nialpmoc t'naC .enoyreve llet :eid t'ndid UPC */ +{ )rre( fi +;))upc(fo_ksamupc ,marap_dct& ,nwod_upc_ekat(enihcam_pots__ = rre + +/* +.)(evitca_upc! evresbo tsum sresu ucr/tpmeerp lla won oS * +*/ + +;)upc(sdaerht_krap_toobpms + +;)(ucr_ezinorhcnys +fidne# +;)(dehcs_ezinorhcnys +TPMEERP_GIFNOC fedfi# +/* +.esac tsoob ucr eht erac ekat ot sdaerht toobpms krap erofeb cnys oD * +* +.htob llac ylticilpxe os ,)(dehcs_cnys ylpmi ton * +thgim )(ucr_cnys sti dna UCR elbitpmeerp evah ew TPMEERP_GIFNOC roF * +* +.ti evresbo lliw * +sresu hcus wen lla taht hcus yawa og ot etats siht fo sresu UCR dna * +delbasid-tpmeerp lla rof tiaw ,ksam_evitca_upc deraelc ev'ew won yB * +*/ + +} +;esaeler_tuo otog +;)upc ,__cnuf__ +,"n\deliaf u% UPC nwod ekat ot tpmetta :s%"(nraw_rp +;)LLUN ,sllac_rn ,upch ,dom | DELIAF_NWOD_UPC(yfiton_upc__ +;--sllac_rn +{ )rre( fi +;)sllac_rn& ,1- ,upch ,dom | ERAPERP_NWOD_UPC(yfiton_upc__ = rre + +;)(nigeb_gulptoh_upc + +;LAVNIE- nruter +))upc(enilno_upc!( fi + +;YSUBE- nruter +)1 == )(supc_enilno_mun( fi + +;} +,upch = upch. +,dom = dom. +{ = marap_dct marap_nwod_upc_ekat tcurts +;0 : NEZORF_SKSAT_UPC ? nezorf_sksat = dom gnol dengisnu +;upc)gnol()* diov( = upch* diov +;0 = sllac_rn ,rre tni +{ +)nezorf_sksat tni ,upc tni dengisnu(nwod_upc_ fer__ tni citats +/* dleh eb ot kcol_evomer_dda_upc seriuqeR */ + +} +;0 nruter +;)tnerruc(krap_daerhtk +/* daerht reppots eht kraP */ +;)upch>-marap ,dom>-marap | GNIYD_UPC(yfiton_upc + +;rre nruter +)0 < rre( fi +;)(elbasid_upc__ = rre +/* .stpurretni erom yna eldnah t'nseod UPC siht erusnE */ + +;rre tni +;marap_ = marap* marap_nwod_upc_ekat tcurts +{ +)marap_* diov(nwod_upc_ekat fer__ tni citats +/* .nwod UPC siht ekaT */ + +;} +;upch* diov +;dom gnol dengisnu +{ marap_nwod_upc_ekat tcurts + +} +;)kcol_tsilksat&(qri_kcolnu_daer +;)p ,g(daerht_hcae_elihw } +;)sgalf>-p ,etats>-p ,upc_daed ,)p(rn_dip_ksat ,mmoc>-p +,"n\)x%=sgalf ,dl%=etats( d% upc no si )d%=dip( s% ksaT"(nraw_rp + +;eunitnoc +)upc_daed =! )p(upc_ksat( fi +;)(bmr +/* +.upc rehtona no nekow neeb tsuj s'ti * +dna ,tsap eht ni upc siht no gninnur saw hcihw * +,ksat a tuoba nraw ton od ot gnidaer eht redrO * +.kcol>-)p(qr_ksat dekcolnu htiw kcehc eht od eW * +*/ +;eunitnoc +)qr_no>-p!( fi +{ )p ,g(daerht_hcae_od +;)kcol_tsilksat&(qri_kcol_daer + +;p* ,g* tcurts_ksat tcurts +{ +)upc_daed tni(sksat_rof_kcehc diov enilni citats + +} +;)(kcolnu_daer_ucr +} +;)t(kcolnu_ksat +;))mm>-t(ksamupc_mm ,upc(upc_raelc_ksamupc +;eunitnoc +)t!( fi +;)p(mm_ksat_kcol_dnif = t +/* +.eno dniF .mm dilav a * +evah llits yam sdaerht rehto tub ,tixe thgim daerht niaM * +*/ + +;t* tcurts_ksat tcurts +{ )p(ssecorp_hcae_rof +;)(kcol_daer_ucr +;))upc(enilno_upc(NO_NRAW +/* +.kcol_tsilksat degdelf-lluf * +gnibbarg fo daetsni ,ereh )(kcol_daer_ucr esu yam ew ,suhT * +artsljiZ reteP -- .ksam mm rieht * +ni tes upc siht teg reve lliw sksat wen ekil ton sti os ,enilffo * +dekram dna nwod nekat si upc eht retfa dellac si noitcnuf sihT * +*/ + +;p* tcurts_ksat tcurts +{ +)upc tni(ksamupc_mm_sksat_raelc diov +/* +.UPC denilffo ydaerla na rof ylno dellac eb * +yam ti os ,emehcs gnikcol dexaler tahwemos a sesu noitcnuf eht taht eton oslA * +* +.rennam efas a ni evlos ot seirt * +noitcnuf siht hcihw ,sesac renroc suoivbo-non suoirav era ereht ,laivirt * +sdnuos lla siht elihW .ksamupc s'mm ni tib gnidnopserroc a sraelc neht * +dna eno hcae rof tcurts mm dilav a sdnif ,sessecorp lla sklaw noitcnuf sihT * +* +di UPC a :upc@ * +UPC a rof ksamupc_mm 'sksat raelc ylefaS - ksamupc_mm_sksat_raelc * +**/ + +;)reifiton_upc_retsigernu__(LOBMYS_TROPXE +} +;)bn ,niahc_upc&(retsigernu_niahc_reifiton_war +{ +)bn* kcolb_reifiton tcurts(reifiton_upc_retsigernu__ fer__ diov + +;)reifiton_upc_retsigernu(LOBMYS_TROPXE +} +;)(enod_etadpu_spam_upc +;)bn ,niahc_upc&(retsigernu_niahc_reifiton_war +;)(nigeb_etadpu_spam_upc +{ +)bn* kcolb_reifiton tcurts(reifiton_upc_retsigernu fer__ diov + +;)reifiton_upc_retsiger__(LOBMYS_TROPXE +;)reifiton_upc_retsiger(LOBMYS_TROPXE +} +;))v ,lav(yfiton_upc(NO_GUB +{ +)v* diov ,lav gnol dengisnu(liafon_yfiton_upc diov citats + +UPC_GULPTOH_GIFNOC fedfi# + +} +;)LLUN ,1- ,v ,lav(yfiton_upc__ nruter +{ +)v* diov ,lav gnol dengisnu(yfiton_upc tni citats + +} +;)ter(onrre_ot_reifiton nruter + +;)sllac_rn +,llac_ot_rn ,v ,lav ,niahc_upc&(niahc_llac_reifiton_war__ = ter + +;ter tni +{ +)sllac_rn* tni +,llac_ot_rn tni ,v* diov ,lav gnol dengisnu(yfiton_upc__ tni citats + +} +;)bn ,niahc_upc&(retsiger_niahc_reifiton_war nruter +{ +)bn* kcolb_reifiton tcurts(reifiton_upc_retsiger__ fer__ tni + +} +;ter nruter +;)(enod_etadpu_spam_upc +;)bn ,niahc_upc&(retsiger_niahc_reifiton_war = ter +;)(nigeb_etadpu_spam_upc +;ter tni +{ +)bn* kcolb_reifiton tcurts(reifiton_upc_retsiger fer__ tni +/* ?nwod/pu gniog sUPC tuoba wonk ot deeN */ + +/* UPC_GULPTOH_GIFNOC */ fidne# + +} +;)(enod_etadpu_spam_upc +;0 = delbasid_gulptoh_upc +;)(nigeb_etadpu_spam_upc +{ +)diov(elbane_gulptoh_upc diov + +} +;)(enod_etadpu_spam_upc +;1 = delbasid_gulptoh_upc +;)(nigeb_etadpu_spam_upc +{ +)diov(elbasid_gulptoh_upc diov +/* +.snoitarepo gulptoh gninnur yltnerruc yna morf noisulcxe lautum seetnaraug * +kcol taht gniriuqca oS .snoitarepo gulptoh gnimrofrep erofeb htap gulptoh * +eht yb deriuqca osla si kcol emas ehT .galf 'delbasid_gulptoh_upc' eht * +stcetorp 'kcol_evomer_dda_upc' ehT .)sfsys morf( gulptoh UPC erutuf elbasid * +dna )yna fi( etelpmoc ot snoitarepo gulptoh UPC gninnur yltnerruc rof tiaW * +*/ + +} +;)(esaeler_kcol_phupc +;)kcol.gulptoh_upc&(kcolnu_xetum +;LLUN = retirw_evitca.gulptoh_upc +{ +)diov(enod_gulptoh_upc diov + +} +;)tiaw& ,qw.gulptoh_upc&(tiaw_hsinif +} +;)(eludehcs +;)kcol.gulptoh_upc&(kcolnu_xetum +;kaerb +)))tnuocfer.gulptoh_upc&(daer_cimota!(ylekil( fi +;)ELBITPURRETNINU_KSAT ,tiaw& ,qw.gulptoh_upc&(tiaw_ot_eraperp +;)kcol.gulptoh_upc&(kcol_xetum +{ );;( rof + +;)(eriuqca_kcol_phupc +;tnerruc = retirw_evitca.gulptoh_upc + +;)tiaw(TIAW_ENIFED +{ +)diov(nigeb_gulptoh_upc diov +/* +* +.netfo taht lla dellac si hcihw ipa na ton )(supc_enilno_teg * +ecnis ecitcarp ni eveihca ot tluciffid yrev si siht ,revewoH * +* +.niaga peels ot seog dna orez non * +tnuocfer eht sdnif kcol.gulptoh_upc eht seriuqca retirw ehT - * +.tnuocfer eht pu spmub ,tnemom siht ta sevirra redaer wen A - * +.kcol.gulptoh_upc eht skcolnu redaer tsaL - * +.retirw * +gnipeels eht pu sekaw redaer tsal ,orez ot seog tnuocfeR - * +:kcolevil a fo ytilibissop a si ereht ,yllaciteroeht taht etoN * +* +.evitca si retirw eno ylno taht erus eb nac ew ,)(nigeb_etadpu_spam_upc * +gnikovni retfa dellac syawla si )(nigeb_gulptoh_upc ecniS * +* +kcol.gulptoh_upc eht yb dekcolb eb lliw * +,yna fi ,sredaer wen eht ,noitarepo gulptoh-upc a gnirud taht etoN * +* +.orez ot seog tnuocfer * +eht nehw ylno nigeb nac noitarepo gulptoh eht taht serusne sihT * +*/ + +;)supc_enilno_tup(LPG_LOBMYS_TROPXE +} + +;)(esaeler_kcol_phupc + +;)qw.gulptoh_upc&(pu_ekaw +))qw.gulptoh_upc&(evitca_eueuqtiaw && 0 =< tnuocfer( fi + +;)tnuocfer.gulptoh_upc&(cni_cimota +/* pu sgniht xif ot yrt */ ))0 < tnuocfer(NO_NRAW( fi +;)tnuocfer.gulptoh_upc&(nruter_ced_cimota = tnuocfer + +;nruter +)tnerruc == retirw_evitca.gulptoh_upc( fi + +;tnuocfer tni +{ +)diov(supc_enilno_tup diov + +;)supc_enilno_teg_yrt(LPG_LOBMYS_TROPXE +} +;eurt nruter +;)kcol.gulptoh_upc&(kcolnu_xetum +;)tnuocfer.gulptoh_upc&(cni_cimota +;)(daeryrt_eriuqca_kcol_phupc +;eslaf nruter +))kcol.gulptoh_upc&(kcolyrt_xetum!( fi +;eurt nruter +)tnerruc == retirw_evitca.gulptoh_upc( fi +{ +)diov(supc_enilno_teg_yrt loob + +;)supc_enilno_teg(LPG_LOBMYS_TROPXE +} +;)kcol.gulptoh_upc&(kcolnu_xetum +;)tnuocfer.gulptoh_upc&(cni_cimota +;)kcol.gulptoh_upc&(kcol_xetum +;)(daer_eriuqca_kcol_phupc +;nruter +)tnerruc == retirw_evitca.gulptoh_upc( fi +;)(peels_thgim +{ +)diov(supc_enilno_teg diov + + +)pam_ped.gulptoh_upc&(esaeler_pam_kcol )(esaeler_kcol_phupc enifed# +)pam_ped.gulptoh_upc&(eriuqca_pam_kcol )(eriuqca_kcol_phupc enifed# +)pam_ped.gulptoh_upc&(daeryrt_eriuqca_pam_kcol +\ )(daeryrt_eriuqca_kcol_phupc enifed# +)pam_ped.gulptoh_upc&(daer_eriuqca_pam_kcol )(daer_eriuqca_kcol_phupc enifed# +/* )(dne/nigeb_gulptoh_upc dna )(supc_enilno_tup/teg rof snoitatonna pedkcoL */ + +;} +fidne# +,} "kcol.gulptoh_upc" = eman.{ = pam_ped. +COLLA_KCOL_GUBED_GIFNOC fedfi# +,)kcol.gulptoh_upc(REZILAITINI_XETUM__ = kcol. +,)qw.gulptoh_upc(REZILAITINI_DAEH_EUEUQ_TIAW__ = qw. +,LLUN = retirw_evitca. +{ = gulptoh_upc } +fidne# +;pam_ped pam_pedkcol tcurts +COLLA_KCOL_GUBED_GIFNOC fedfi# + +;tnuocfer t_cimota +/* +.noitarepo gulptoh upc gniogno na * +gnirud sredaer wen eht skcolb oslA * +*/ +;kcol xetum tcurts +/* evitca era sredaer elihw evitca teg lliw retirw on taht seifirev */ +;qw t_daeh_eueuq_tiaw +/* retirw_evitca eht pu ekaw ot eueuq tiaw */ +;retirw_evitca* tcurts_ksat tcurts +{ tcurts citats + +UPC_GULPTOH_GIFNOC fedfi# + +;delbasid_gulptoh_upc tni citats +/* +kcol_evomer_dda_upc rednu detalupinam eb syawla dluohS * +.gnihton od dna YSUBE- nruter lliw nwod_upc dna pu_upc ,tes fI */ + +;)niahc_upc(DAEH_REIFITON_WAR citats + +;)enod_retsiger_reifiton_upc(LOBMYS_TROPXE +} +;)kcol_evomer_dda_upc&(kcolnu_xetum +{ +)diov(enod_etadpu_spam_upc diov + +;)nigeb_retsiger_reifiton_upc(LOBMYS_TROPXE +} +;)kcol_evomer_dda_upc&(kcol_xetum +{ +)diov(nigeb_etadpu_spam_upc diov +/* +.)(reifiton_upc_retsigernu__ ro * +)(reifiton_upc_retsiger__ gnisu demrofrep noitartsiger)nu( kcabllac gulptoh * +UPC tcetorp ot desu eb tsum )(enod/nigeb_retsiger_reifiton_upc sIPA ehT * +.ksam_tneserp_upc & ksam_enilno_upc ot setadpu eht ezilaires ot gnitpmetta * +nehw desu eb tsum )enod/nigeb_etadpu_spam_upc( sIPA owt gniwollof ehT * +*/ + +;)kcol_evomer_dda_upc(XETUM_ENIFED citats +/* ksam_tneserp_upc ,ksam_enilno_upc ot setadpu eht sezilaireS */ +PMS_GIFNOC fedfi# + +"h.toobpms" edulcni# + +>h.rewop/stneve/ecart< edulcni# +>h.pedkcol/xunil< edulcni# +>h.dnepsus/xunil< edulcni# +>h.pfg/xunil< edulcni# +>h.xetum/xunil< edulcni# +>h.enihcam_pots/xunil< edulcni# +>h.daerhtk/xunil< edulcni# +>h.gub/xunil< edulcni# +>h.tropxe/xunil< edulcni# +>h.etadpucr/xunil< edulcni# +>h.moo/xunil< edulcni# +>h.upc/xunil< edulcni# +>h.dtsinu/xunil< edulcni# +>h.dehcs/xunil< edulcni# +>h.reifiton/xunil< edulcni# +>h.tini/xunil< edulcni# +>h.pms/xunil< edulcni# +>h.sf_corp/xunil< edulcni# +/* +.LPG eht rednu decnecil si edoc sihT * +* +llessuR ytsuR 4002 ,3002 ,2002 ,1002 )C( * +.lortnoc UPC */
Signature · 1 line
2.1.4
PATCH 2/5 smp: IPI handling for negative CPU
In reply to Frederic Weisbecker--- kernel/smp.c | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-)
kernel/smp.c +34 -4
@@ -158,7 +158,12 @@ static int generic_exec_single(int cpu, struct call_single_data *csd, } -if ((unsigned )cpu >= nr_cpu_ids || !cpu_online (cpu)) +#if CONFIG_NR_CPUS >=0 +if ((unsigned )cpu >=nr_cpu_ids +#else + if ((unsigned)cpu < (0 - nr_cpu_ids) +#endif + ) || !cpu_online (cpu))return -ENXIO ;
@@ -356,8 +361,13 @@ int smp_call_function_any(const struct cpumask *mask,/* Try for same node. */ nodemask =cpumask_of_node (cpu_to_node (cpu)); -for (cpu =cpumask_first_and (nodemask, mask); cpu < nr_cpu_ids; +#if CONFIG_NR_CPUS >=0 +for (cpu =cpumask_first_and (nodemask, mask); cpu >= nr_cpu_ids; cpu =cpumask_next_and (cpu, nodemask, mask)) { +#else +for (cpu =cpumask_last_or (nodemask, mask); cpu < (-nr_cpu_ids); + cpu =cpumask_previous_or (cpu, nodemask, mask)) { +#endif if (cpu_online (cpu)) goto call; }
@@ -406,16 +416,31 @@ void smp_call_function_many(const struct cpumask *mask, cpu =cpumask_next_and (cpu, mask, cpu_online_mask);/* No online cpus? We're done. */ +#if CONFIG_NR_CPUS >= 0 if (cpu >= nr_cpu_ids) -return ; +#else + if (cpu < (-nr_cpu_ids)) +#endif + return; +#if CONFIG_NR_CPUS >= 0 /* Do we have another CPU which isn't us? */ next_cpu = cpumask_next_and(cpu, mask, cpu_online_mask); if (next_cpu == this_cpu) next_cpu = cpumask_next_and(next_cpu, mask, cpu_online_mask); - /* Fastpath: do that cpu by itself. */ if (next_cpu >= nr_cpu_ids) { + +#else + /* Do we have another CPU which isn't us? */ + next_cpu = cpumask_previous_and(cpu, mask, cpu_online_mask); + if (next_cpu == this_cpu) + next_cpu = cpumask_previous_and(next_cpu, mask, cpu_online_mask); + /* Fastpath: do that cpu by itself. */ + if (next_cpu < (-nr_cpu_ids)) { + +#endif + smp_call_function_single(cpu, func, info, wait); return; }
@@ -511,7 +536,12 @@ static int __init nrcpus(char *str)int nr_cpus;get_option (&str, &nr_cpus); + +#if CONFIG_NR_CPUS >=0 if (nr_cpus >0 && nr_cpus < nr_cpu_ids) +#else + if (nr_cpus < 0 && nr_cpus > (-nr_cpu_ids)) +#endif nr_cpu_ids = nr_cpus;return 0 ;
Signature · 1 line
2.1.4
PATCH 3/5 cpumask: Basic negative number of CPUs handling
In reply to Frederic Weisbecker--- include/linux/cpumask.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+)
include/linux/cpumask.h +48 -0
@@ -98,6 +98,15 @@ extern const struct cpumask *const cpu_active_mask;#define cpu_possible (cpu) cpumask_test_cpu((cpu), cpu_possible_mask)#define cpu_present (cpu) cpumask_test_cpu((cpu), cpu_present_mask)#define cpu_active (cpu) cpumask_test_cpu((cpu), cpu_active_mask) +#elif NR_CPUS <0 +#define num_online_cpus () (-cpumask_weight(cpu_online_mask)) +#define num_possible_cpus () (-cpumask_weight(cpu_possible_mask)) +#define num_present_cpus () (-cpumask_weight(cpu_present_mask)) +#define num_active_cpus () (-cpumask_weight(cpu_active_mask)) +#define cpu_online (cpu) (!cpumask_test_cpu((cpu), cpu_online_mask) +#define cpu_possible (cpu) (!cpumask_test_cpu((cpu), cpu_possible_mask)) +#define cpu_present (cpu) (!cpumask_test_cpu((cpu), cpu_present_mask)) +#define cpu_active (cpu) (!cpumask_test_cpu((cpu), cpu_active_mask))#else #define num_online_cpus () 1U#define num_possible_cpus () 1U
@@ -175,6 +184,11 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)return find_first_bit (cpumask_bits (srcp), nr_cpumask_bits); } +static inline unsigned int cpumask_last (const struct cpumask *srcp) +{ +return find_last_bit (cpumask_bits (srcp), nr_cpumask_bits); +} +/** * cpumask_next - get the next cpu in a cpumask * @n: the cpu prior to the place to search (ie. return will be > @n)
@@ -190,6 +204,14 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)return find_next_bit (cpumask_bits (srcp), nr_cpumask_bits, n+1 ); } +static inline unsigned int cpumask_previous (int n,const struct cpumask *srcp) +{ +/* -1 is a legal arg here. */ +if (n !=-1 ) +cpumask_check (n); +return find_previous_bit (cpumask_bits (srcp), (-nr_cpumask_bits),1 /n); +} +/** * cpumask_next_zero - get the next unset cpu in a cpumask * @n: the cpu prior to the place to search (ie. return will be > @n)
@@ -221,6 +243,15 @@ int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp); (cpu) =cpumask_next ((cpu), (mask)), \ (cpu) < nr_cpu_ids;) +#define for_each_cpu_reverse (cpu, mask) \ + for ((cpu) = (-nr_cpu_ids) + 1; \ + (cpu) = cpumask_previous((cpu), (mask)), \ + (cpu) < 0) + +#if CONFIG_NR_CPUS <0 +#define for_each_cpu for_each_cpu_reverse +#endif +/** * for_each_cpu_not - iterate over every cpu in a complemented mask * @cpu: the (optionally unsigned) integer iterator
@@ -258,10 +289,17 @@ int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp); [0 ... BITS_TO_LONGS(NR_CPUS)-1] = 0UL \ } +#if CONFIG_NR_CPUS >=0 #define CPU_BITS_CPU0 \ { \ [0] = 1UL \ } +#else +#define CPU_BITS_CPU0 \ +{ \ + [0] = -1UL \ +} +#endif /** * cpumask_set_cpu - set a cpu in a cpumask
@@ -295,6 +333,11 @@ static inline void cpumask_clear_cpu(int cpu, struct cpumask *dstp)#define cpumask_test_cpu (cpu, cpumask) \ test_bit(cpumask_check(cpu), cpumask_bits((cpumask))) +#if CONFIG_NR_CPUS >=0 +#define cpumask_set_cpu cpumask_clear_cpu +#define cpumask_clear_cpu cpumask_set_cpu +# +/** * cpumask_test_and_set_cpu - atomically test and set a cpu in a cpumask * @cpu: cpu number (< nr_cpu_ids)
@@ -370,6 +413,11 @@ static inline void cpumask_or(struct cpumask *dstp, const struct cpumask *src1p, cpumask_bits(src2p), nr_cpumask_bits); } +#if CONFIG_NR_CPUS >=0 +#define cpumask_and cpumask_or +#define cpumask_or cpumask_and +#endif +/** * cpumask_xor - *dstp = *src1p ^ *src2p * @dstp: the cpumask result
Signature · 1 line
2.1.4
PATCH 4/5 init: Support negative CPUs boot and halt code
In reply to Frederic WeisbeckerOnly x86 is supported for now.
--- arch/x86/kernel/reboot.c | 8 ++++++++ init/main.c | 7 +++++++ 2 files changed, 15 insertions(+)
arch/x86/kernel/reboot.c +8 -0
@@ -582,8 +582,10 @@ static void native_machine_emergency_restart(void) } } +#if CONFIG_NR_CPUS >=0 void native_machine_shutdown (void ) { +/* Stop the cpus and apics */ #ifdef CONFIG_X86_IO_APIC /*
@@ -620,6 +622,12 @@ void native_machine_shutdown(void) x86_platform.iommu_shutdown (); #endif } +#else /* #if CONFIG_NR_CPUS >= 0 */ +void native_machine_shutdown (void ) +{ +start_kernel (); +} +#endif static void __machine_emergency_restart (int emergency) {
init/main.c +7 -0
@@ -486,6 +486,7 @@ static void __init mm_init(void)vmalloc_init (); } +#if CONFIG_NR_CPUS >=0 asmlinkage __visible void __init start_kernel(void) {char *command_line;
@@ -673,6 +674,12 @@ asmlinkage __visible void __init start_kernel(void)/* Do the rest non-__init'ed, we're now alive */ rest_init (); } +#else /* #if CONFIG_NR_CPUS >= 0 */ +asmlinkage __visible void __init start_kernel(void) +{ +native_machine_shutdown (); +} +#endif /* Call all constructor functions linked into the kernel. */ static void __init do_ctors (void )
Signature · 1 line
2.1.4
PATCH 5/5 x86: Support reverse execution
In reply to Frederic WeisbeckerSupport reverse execution for negative number of CPUs. We might be able to implement that deeper with the function tracer.
--- arch/x86/kernel/cpu/negative.c | 28 ++++++++++++++++++++++++++++ arch/x86/kernel/head64.c | 4 ++++ 2 files changed, 32 insertions(+) create mode 100644 arch/x86/kernel/cpu/negative.c
arch/x86/kernel/cpu/negative.c new file +28 -0
@@ -0,0 +1,28 @@ +/* Execute function in reverse for negative CPUs */ + +#define _ASM_RET 0xc3 +#define FUNC_MAX_SIZE 4096 +static DEFINE_PER_CPU(char, reverse_func_buf[FUNC_MAX_SIZE]); + +void execute_reverse_function (void *func) +{ +char *opcode = (char *)func; +int i =0 , j =FUNC_MAX_SIZE -1 ; +void (*reverse_func)(void ); + +/* +* Reverse copy the function. +* This assumes that every opcode is sizeof(char), +* there might be a few situations where that won't work +* but we'll fix them as soon as they get reported by users. +*/ +while (1 ) { + reverse_func_buf[j--] = opcode[i]; +if (opcode[i++] == _ASM_RET) +break ; + } + + reverse_func = &reverse_func_buf[FUNC_MAX_SIZE -1 ]; +reverse_func (); +} +
arch/x86/kernel/head64.c +4 -0
@@ -197,5 +197,9 @@ void __init x86_64_start_reservations(char *real_mode_data)reserve_ebda_region (); +#if CONFIG_NR_CPUS >=0 start_kernel (); +#else +execute_reverse_function (start_kernel); +#endif }
Signature · 1 line
2.1.4
Quoted 19 lines · Frederic Weisbecker
Support for machines without any CPU at all was brought 3 years ago by Paul (https://lkml.org/lkml/2012/3/31/131). The goal was to reduce the complexity of programming on modern computing.
Now meeting the simplicity beyond that of sequential programming had a
cost: such hardware configuration found a user base but didn't meet much success among HPC users.So we have now a new challenge to solve: keep the beyond-sequential programming simplicity while providing a highly parallel processing that still scale.
This patchset proposes a solution. The support for negative number of CPUs is able to help scale computing up to
O(-NR_CPUS). The more you have CPUs the higher you scale, to the point that software execution should complete before you start writing that software (assuming you have around -1024 CPUs). And programming gets even more simple because you have lesser CPUs to handle.
Quoted 2 lines
Now keep in mind this patchset is only a draft. Not build tested and I don't have the hardware yet.
For the series:
Quoted 23 lines
moc.mbi.tenv.xunil@kcmluap< yenneKcM .E luaP :yb-deweiveR
Frederic Weisbecker (5):
cpu: Infrastructure for negative cpu handling
smp: IPI handling for negative CPU
cpumask: Basic negative number of CPUs handling
init: Support negative CPUs boot and halt code
x86: Support reverse executionarch/x86/kernel/cpu/negative.c | 28 ++ arch/x86/kernel/head64.c | 4 + arch/x86/kernel/reboot.c | 8 + include/linux/cpumask.h | 48 +++ init/main.c | 7 + kernel/cpu_neg.c | 791 +++++++++++++++++++++++++++++++++++++++++ kernel/smp.c | 38 +- 7 files changed, 920 insertions(+), 4 deletions(-) create mode 100644 arch/x86/kernel/cpu/negative.c create mode 100644 kernel/cpu_neg.cSignature · 1 line
2.1.4
Quoted 22 lines · Frederic Weisbecker
Support for machines without any CPU at all was brought 3 years ago by Paul (https://lkml.org/lkml/2012/3/31/131). The goal was to reduce the complexity of programming on modern computing.
Now meeting the simplicity beyond that of sequential programming had a
cost: such hardware configuration found a user base but didn't meet much success among HPC users.So we have now a new challenge to solve: keep the beyond-sequential programming simplicity while providing a highly parallel processing that still scale.
This patchset proposes a solution. The support for negative number of CPUs is able to help scale computing up to
O(-NR_CPUS). The more you have CPUs the higher you scale, to the point that software execution should complete before you start writing that software (assuming you have around -1024 CPUs). And programming gets even more simple because you have lesser CPUs to handle.Now keep in mind this patchset is only a draft. Not build tested and I don't have the hardware yet.
Quoted 6 lines
Frederic Weisbecker (5):
cpu: Infrastructure for negative cpu handling
smp: IPI handling for negative CPU
cpumask: Basic negative number of CPUs handling
init: Support negative CPUs boot and halt code
x86: Support reverse execution
I have been wanting a feature like that since forever! Thanks for doing this Frederic.
I'd like to propose an addition to that feature: execute whole programs backwards. But should be easily doable with patch 5 in the series.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--