percpu_freelist.h 929 B

1234567891011121314151617181920212223242526272829303132
  1. /* Copyright (c) 2016 Facebook
  2. *
  3. * This program is free software; you can redistribute it and/or
  4. * modify it under the terms of version 2 of the GNU General Public
  5. * License as published by the Free Software Foundation.
  6. */
  7. #ifndef __PERCPU_FREELIST_H__
  8. #define __PERCPU_FREELIST_H__
  9. #include <linux/spinlock.h>
  10. #include <linux/percpu.h>
  11. struct pcpu_freelist_head {
  12. struct pcpu_freelist_node *first;
  13. raw_spinlock_t lock;
  14. };
  15. struct pcpu_freelist {
  16. struct pcpu_freelist_head __percpu *freelist;
  17. };
  18. struct pcpu_freelist_node {
  19. struct pcpu_freelist_node *next;
  20. };
  21. void pcpu_freelist_push(struct pcpu_freelist *, struct pcpu_freelist_node *);
  22. struct pcpu_freelist_node *pcpu_freelist_pop(struct pcpu_freelist *);
  23. void pcpu_freelist_populate(struct pcpu_freelist *s, void *buf, u32 elem_size,
  24. u32 nr_elems);
  25. int pcpu_freelist_init(struct pcpu_freelist *);
  26. void pcpu_freelist_destroy(struct pcpu_freelist *s);
  27. #endif