KernelNewbies
  • Comments
  • Immutable Page
  • Menu
    • Navigation
    • RecentChanges
    • FindPage
    • Local Site Map
    • Help
    • HelpContents
    • HelpOnMoinWikiSyntax
    • Display
    • Attachments
    • Info
    • Raw Text
    • Print View
    • Edit
    • Load
    • Save
  • Login

Kernel Hacking

  • Frontpage

  • Kernel Hacking

  • Kernel Documentation

  • Kernel Glossary

  • FAQ

  • Found a bug?

  • Kernel Changelog

  • Upstream Merge Guide

Projects

  • KernelJanitors

  • KernelMentors

  • KernelProjects

Community

  • Why a community?

  • Regional Kernelnewbies

  • Personal Pages

  • Upcoming Events

References

  • Mailing Lists

  • Related Sites

  • Programming Links

Wiki

  • Recent Changes

  • Site Editors

  • Side Bar

  • Tips for Editors

  • Hosted by WikiWall

Navigation

  • RecentChanges
  • FindPage
  • HelpContents
Revision 3 as of 2024-05-15 18:42:00
KernelNewbies:
  • MatthewWilcox
  • FolioAlloc

Today with folios being an overlay on struct page, folio_alloc() is simple; we allocate a compound page and cast the result to a struct folio pointer.

Once we live in a MatthewWilcox/Memdescs world, we need to do two allocations. First, we allocate a struct folio from slab. Then we call into the MatthewWilcox/BuddyAllocator to allocate the memory. I envisage a function like this:

struct folio *folio_alloc(gfp_t gfp, unsigned int order)
{
        struct page *page;
        struct folio *folio = kmem_cache_alloc(folio_slab, gfp);

        if (!folio)
                return NULL;
        page = alloc_page_desc(gfp, order, MEMDESC_TYPE_FOLIO, folio);
        if (!page) {
                kmem_cache_free(folio_slab, folio);
                return NULL;
        }
        folio->pfn = page_to_pfn(page);
        return folio;
}
  • MoinMoin Powered
  • Python Powered
  • GPL licensed
  • Valid HTML 4.01