Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SLUB data structures

SLUB data structures

Masami Ichikawa

November 30, 2014
Tweet

More Decks by Masami Ichikawa

Other Decks in Programming

Transcript

  1. 3&"%.& w ͜ͷεϥΠυ͸ҎԼͷ఺ʹߜͬͯ·͢ w 4-6#ͷσʔλߏ଄ w TMBCDBDIFͷ࡞੒ w Լهࢿྉʹ͋Δ4-6#EBUBTUSVDUVSFTΛཧղ͢Δ w

    IUUQFWFOUTMJOVYGPVOEBUJPOPSHTJUFTFWFOUTpMFT TMJEFTTMBCBMMPDBUPSTQEG w NFNPSZDPOUSPMHSPVQ΋བྷΉͷͰ͕͢ɺͦ͜͸ؾʹ͠ͳ͍ํ ޲ͰίʔυϦʔσΟϯάͯ͠·͢
  2. 4MBCBMMPDBUPS JNQMFNFOUBUJPOTJO-JOVY w -JOVYʹ͓͚Δ4MBCBMMPDBUPS࣮૷ͷҰͭ w 4-"# w 4VO04ͷ4MBCBMMPDBUPSΞϧΰϦζϜʹجͮ͘ w 4-6#

    w ͔ΒσϑΥϧτͷ4MBCBMMPDBUPSʹ w ϝϞϦͷϑϥάϝϯςʔγϣϯ͕ൃੜ͠ʹ͍͘ w 4-0# w αΠζͷখ͍͞BMMPDBUPS
  3. 4-6#NFSHF w εϥϒΩϟογϡ࡞੒࣌ʹ͢ͰʹಉαΠζͷεϥϒ͕͋Ε͹ͦ͜ ʹϚʔδ w TMBCJOGPBͰϚʔδ͞Εͨ4MBCΛ֬ೝՄೳ w LFSOFMTPVSDFUSFFʹ͋ΔUPPMTWNTMBCJOGPD :at-0000104 <-

    sda1 buffer_head :at-0000320 <- jbd2_transaction_s nfs_direct_cache :t-0000024 <- scsi_data_buffer numa_policy :t-0000032 <- sd_ext_cdb dnotify_struct kmalloc-32 :t-0000040 <- khugepaged_mm_slot Acpi-Namespace ext4_system_zone
  4. .BJOTUSVDUVSFT w TUSVDULNFN@DBDIF w JODMVEFMJOVYTMVC@EFGI w TMBCPCKFDUΛ؅ཧ͢Δߏ଄ମ w Լهͷͭͷߏ଄ମ͸LNFN@DBDIFߏ଄ମͷϝϯόม਺ w

    TUSVDULNFN@DBDIF@DQV w JODMVEFMJOVYTMVC@EFGI w TMBCPCKFDU΁ͷΞΫηε͸͔͜͜Β w TUSVDULNFN@DBDIF@OPEF w NNTMBCI w /6."ϊʔυຖͷTMBCΛࢦ͢ w TUSVDUQBHF w GSFFMJTU΁ͷϙΠϯλɺΦϒδΣΫτ࢖༻਺ͳͲͷม਺͕௥Ճ͞Εͨ
  5. 4MBCPCKFDUP⒎TFU w TUSVDULNFN@DBDIFͷม਺P⒎TFU w Լهͷ৚݅ʹ֘౰͢Δ৔߹ɺPCKFDUͷઌ಄ΞυϨεʴP⒎TFUόΠτ໨͔ΒΛTMBC PCKFDUʹ͢Δ w TMBCPCKFDUͷGSFF࣌ʹ3$6Λ࢖͏ w 4-"#@10*40/͕ηοτ͞Ε͍ͯΔ

    w ίϯετϥΫλ͕ࢦఆ͞Ε͍ͯΔ w P⒎TFU͸ԼهͷαΠζʹઃఆ͞ΕΔ w PCKFDUͷαΠζΛTJ[FPG WPJE ͷڥքʹ͋͏Α͏ʹBMJHOͨ͠αΠζ w 4-"#@3&%;0/&͕ηοτ͞Ε͍ͯΔ৔߹͸3&%;0/&ͷαΠζ΋଍͢
  6. TUSVDULNFN@DBDIF TUSVDULNFN@DBDIF\  TUSVDULNFN@DBDIF@DQV@@QFSDQV DQV@TMBC   6TFEGPSSFUSJWJOHQBSUJBMTMBCTFUD  

    VOTJHOFEMPOHqBHT  VOTJHOFEMPOHNJO@QBSUJBM  JOUTJ[F  5IFTJ[FPGBOPCKFDUJODMVEJOHNFUBEBUB   JOUPCKFDU@TJ[F  5IFTJ[FPGBOPCKFDUXJUIPVUNFUBEBUB   JOUP⒎TFU   'SFFQPJOUFSP⒎TFU   JOUDQV@QBSUJBM  /VNCFSPGQFSDQVQBSUJBMPCKFDUTUPLFFQBSPVOE   TUSVDULNFN@DBDIF@PSEFS@PCKFDUTPP ʙུʙ  TUSVDULNFN@DBDIF@OPEF OPEF<."9@/6./0%&4> ^ 4MBC0CKFDUͷ؅ཧ ʹ࢖͏ओͳม਺
  7. TUSVDULNFN@DBDIF@DQV TUSVDULNFN@DBDIF@DQV\  WPJE GSFFMJTU  1PJOUFSUPOFYUBWBJMBCMFPCKFDU   VOTJHOFEMPOHUJE

     (MPCBMMZVOJRVFUSBOTBDUJPOJE   TUSVDUQBHF QBHF  5IFTMBCGSPNXIJDIXFBSFBMMPDBUJOH   TUSVDUQBHF QBSUJBM 1BSUJBMMZBMMPDBUFEGSP[FOTMBCT  JGEFG$0/'*(@4-6#@45"54  VOTJHOFETUBU</3@4-6#@45"5@*5&.4> FOEJG ^
  8. TUSVDULNFN@DBDIF@OPEF TUSVDULNFN@DBDIF@OPEF\  TQJOMPDL@UMJTU@MPDL ʙུʙ JGEFG$0/'*(@4-6#  VOTJHOFEMPOHOS@QBSUJBM  TUSVDUMJTU@IFBEQBSUJBM

    JGEFG$0/'*(@4-6#@%&#6(  BUPNJD@MPOH@UOS@TMBCT  BUPNJD@MPOH@UUPUBM@PCKFDUT  TUSVDUMJTU@IFBEGVMM FOEJG FOEJG EFCVH༻్Λআ͘ͱMJTUͱݸ ਺Λอ࣋͢Δม਺͚ͩ
  9. TUSVDUQBHF  TUSVDU\   VOJPO\    QHP⒎@UJOEFY

      0VSP⒎TFUXJUIJONBQQJOH     WPJE GSFFMJTU   TM<BPV>CpSTUGSFFPCKFDU  ʙུʙ   ^   VOJPO\ ʙུʙ     6TFEGPSDNQYDIH@EPVCMFJOTMVC     VOTJHOFEMPOHDPVOUFST ʙུʙ    TUSVDU\     VOJPO\ ʙུ      TUSVDU\ 4-6#        VOTJHOFEJOVTF       VOTJHOFEPCKFDUT       VOTJHOFEGSP[FO      ^
  10. $SFBUFBTMBC w TMBCͷ࡞੒͸LNFN@DBDIF@DSFBUF  w ,.&.@$"$)& @@TUSVDU @@qBHT ɹϚΫϩ΋͋Δ w

    LNFN@DBDIF@DSFBUF ͷ࣌఺Ͱ͸TMBCPCKFDUTͷ࡞੒͸͠ͳ͍ w GSFFMJTUͷ࡞੒ɺTMBCPCKFDUͷॳظԽͳͲ͸LNFN@DBDIF@BMMPD ࣮ߦ࣌ w ॲཧ͸ஈ֊ w ࠷ॳʹTUSVDULNFN@DBDIFͷΦϒδΣΫτΛऔಘ w ࣍ʹऔಘͨ͠Tͷม਺Λઃఆ TUSVDULNFN@DBDIF  LNFN@DBDIF@DSFBUF DPOTUDIBS OBNF TJ[F@UTJ[F TJ[F@UBMJHO  VOTJHOFEMPOHqBHT WPJE DUPS WPJE
  11. TMBCDSFBUJOHqPX LNFN@DBDIF@DSFBUF  Š@@LNFN@DBDIF@BMJBT  ŠEP@LNFN@DBDIF@DSFBUF  ŠLNFN@DBDIF@[BMMPD  Š@@LNFN@DBDIF@DSFBUF

     ŠLNFN@DBDIF@PQFO  ŠDBMVDBMBUF@TJ[FT  ŠJOJU@LNFN@DBDIF@OPEFT  ŠBMMPD@LNFN@DBDIF@DQVT ओͳͱ͜Ζ
  12. EP@LNFN@DBDIF@DSFBUF w LNFN@DBDIF@[BMMPD ͰTUSVDULNFN@DBDIFߏ଄ମͷΦϒδΣΫτΛऔಘ w LNFN@DBDIFߏ଄ମ͸TMVCͰ؅ཧ͞Ε͍ͯΔ w ͜ΕΛ؅ཧ͍ͯ͠ΔΦϒδΣΫτ͸LNFN@DBDIF w LFSOFMͷॳظԽ࣌ʹLNFN@DBDIF@JOJU

    ʹͯઃఆ w Tͷม਺ΛҰ෦ઃఆ w @@LNFN@DBDIF@DSFBUF ͰTͷઃఆ w TMBC@DBDIFTϦετʹTΛͭͳ͙ w શLNFN@DBDIFߏ଄ମΛͭͳ͍Ͱ͍ΔϦετ
  13. LNFN@DBDIF@[BMMPD w @@('1@;&30Λϑϥάʹઃఆͯ͠LNFN@DBDIF@BMMPD ΛݺͿ͚ͩ w LNFN@DBDIF@BMMPD ͸TMBC@BMMPD ͷϥούʔతͳ΋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ͷPCKFDUͷΞυϨε Λઃఆ TUBUJDJOMJOFWPJETFU@GSFFQPJOUFS TUSVDULNFN@DBDIF T WPJE PCKFDU

    WPJE GQ  \  WPJE PCKFDU TP⒎TFU GQ ^ GPS@FBDI@PCKFDU@JEY Q JEY T TUBSU QBHFPCKFDUT \   TFUVQ@PCKFDU T QBHF Q    JG MJLFMZ JEYQBHFPCKFDUT     TFU@GSFFQPJOUFS T Q Q TTJ[F    FMTF    TFU@GSFFQPJOUFS T Q /6--  ^