This source file includes following definitions.
- extent_align
- LIST_HEAD
- extent_pool_init
- extent_print_all
- extent_create
- extent_destroy
- extent_insert_and_optimize
- extent_alloc_region
- extent_alloc_subregion
- extent_free
- extent_alloc_region_descriptor
- extent_free_region_descriptor
- extent_print
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 #ifdef _KERNEL
45 #include <sys/param.h>
46 #include <sys/extent.h>
47 #include <sys/malloc.h>
48 #include <sys/time.h>
49 #include <sys/systm.h>
50 #include <sys/proc.h>
51 #include <sys/queue.h>
52 #include <sys/pool.h>
53 #include <ddb/db_output.h>
54 #else
55
56
57
58 #include <sys/param.h>
59 #include <sys/pool.h>
60 #include <sys/extent.h>
61 #include <sys/queue.h>
62 #include <errno.h>
63 #include <stdlib.h>
64 #include <stdio.h>
65
66 #define malloc(s, t, flags) malloc(s)
67 #define free(p, t) free(p)
68 #define tsleep(chan, pri, str, timo) (EWOULDBLOCK)
69 #define wakeup(chan) ((void)0)
70 #define pool_get(pool, flags) malloc((pool)->pr_size, 0, 0)
71 #define pool_init(a, b, c, d, e, f, g) (a)->pr_size = (b)
72 #define pool_put(pool, rp) free((rp), 0)
73 #define panic printf
74 #define splvm() (1)
75 #define splx(s) ((void)(s))
76 #endif
77
78 static void extent_insert_and_optimize(struct extent *, u_long, u_long,
79 struct extent_region *, struct extent_region *);
80 static struct extent_region *extent_alloc_region_descriptor(struct extent *, int);
81 static void extent_free_region_descriptor(struct extent *,
82 struct extent_region *);
83
84
85
86
87 static __inline__ u_long
88 extent_align(u_long start, u_long align, u_long skew)
89 {
90 return ((((start - skew) + (align - 1)) & (-align)) + skew);
91 }
92
93
94 #if defined(DIAGNOSTIC) || defined(DDB)
95
96
97
98
99 static LIST_HEAD(listhead, extent) ext_list;
100 static void extent_register(struct extent *);
101
102 static void
103 extent_register(struct extent *ex)
104 {
105 #ifdef DIAGNOSTIC
106 struct extent *ep;
107 #endif
108 static int initialized;
109
110 if (!initialized){
111 LIST_INIT(&ext_list);
112 initialized = 1;
113 }
114
115 #ifdef DIAGNOSTIC
116 LIST_FOREACH(ep, &ext_list, ex_link) {
117 if (ep == ex)
118 panic("extent_register: already registered");
119 }
120 #endif
121
122
123 LIST_INSERT_HEAD(&ext_list, ex, ex_link);
124 }
125 #endif
126
127 struct pool ex_region_pl;
128
129 static void
130 extent_pool_init(void)
131 {
132 static int inited;
133
134 if (!inited) {
135 pool_init(&ex_region_pl, sizeof(struct extent_region), 0, 0, 0,
136 "extentpl", NULL);
137 inited = 1;
138 }
139 }
140
141 #ifdef DDB
142
143
144
145
146 void
147 extent_print_all(void)
148 {
149 struct extent *ep;
150
151 LIST_FOREACH(ep, &ext_list, ex_link) {
152 extent_print(ep);
153 }
154 }
155 #endif
156
157
158
159
160 struct extent *
161 extent_create(char *name, u_long start, u_long end, int mtype, caddr_t storage,
162 size_t storagesize, int flags)
163 {
164 struct extent *ex;
165 caddr_t cp = storage;
166 size_t sz = storagesize;
167 struct extent_region *rp;
168 int fixed_extent = (storage != NULL);
169
170 #ifdef DIAGNOSTIC
171
172 if (name == NULL)
173 panic("extent_create: name == NULL");
174 if (end < start) {
175 printf("extent_create: extent `%s', start 0x%lx, end 0x%lx\n",
176 name, start, end);
177 panic("extent_create: end < start");
178 }
179 if (fixed_extent && (storagesize < sizeof(struct extent_fixed)))
180 panic("extent_create: fixed extent, bad storagesize 0x%lx",
181 (u_long)storagesize);
182 if (fixed_extent == 0 && (storagesize != 0 || storage != NULL))
183 panic("extent_create: storage provided for non-fixed");
184 #endif
185
186 extent_pool_init();
187
188
189 if (fixed_extent) {
190 struct extent_fixed *fex;
191
192 bzero(storage, storagesize);
193
194
195
196
197 fex = (struct extent_fixed *)cp;
198 ex = (struct extent *)fex;
199 cp += ALIGN(sizeof(struct extent_fixed));
200 sz -= ALIGN(sizeof(struct extent_fixed));
201 fex->fex_storage = storage;
202 fex->fex_storagesize = storagesize;
203
204
205
206
207
208 LIST_INIT(&fex->fex_freelist);
209 while (sz >= ALIGN(sizeof(struct extent_region))) {
210 rp = (struct extent_region *)cp;
211 cp += ALIGN(sizeof(struct extent_region));
212 sz -= ALIGN(sizeof(struct extent_region));
213 LIST_INSERT_HEAD(&fex->fex_freelist, rp, er_link);
214 }
215 } else {
216 ex = (struct extent *)malloc(sizeof(struct extent),
217 mtype, (flags & EX_WAITOK) ? M_WAITOK : M_NOWAIT);
218 if (ex == NULL)
219 return (NULL);
220 }
221
222
223 LIST_INIT(&ex->ex_regions);
224 ex->ex_name = name;
225 ex->ex_start = start;
226 ex->ex_end = end;
227 ex->ex_mtype = mtype;
228 ex->ex_flags = 0;
229 if (fixed_extent)
230 ex->ex_flags |= EXF_FIXED;
231 if (flags & EX_NOCOALESCE)
232 ex->ex_flags |= EXF_NOCOALESCE;
233
234 #if defined(DIAGNOSTIC) || defined(DDB)
235 extent_register(ex);
236 #endif
237 return (ex);
238 }
239
240
241
242
243 void
244 extent_destroy(struct extent *ex)
245 {
246 struct extent_region *rp, *orp;
247
248 #ifdef DIAGNOSTIC
249
250 if (ex == NULL)
251 panic("extent_destroy: NULL extent");
252 #endif
253
254
255 for (rp = LIST_FIRST(&ex->ex_regions);
256 rp != LIST_END(&ex->ex_regions); ) {
257 orp = rp;
258 rp = LIST_NEXT(rp, er_link);
259 LIST_REMOVE(orp, er_link);
260 extent_free_region_descriptor(ex, orp);
261 }
262
263 #if defined(DIAGNOSTIC) || defined(DDB)
264
265 LIST_REMOVE(ex, ex_link);
266 #endif
267
268
269 if ((ex->ex_flags & EXF_FIXED) == 0)
270 free(ex, ex->ex_mtype);
271 }
272
273
274
275
276
277
278
279
280 static void
281 extent_insert_and_optimize(struct extent *ex, u_long start, u_long size,
282 struct extent_region *after, struct extent_region *rp)
283 {
284 struct extent_region *nextr;
285 int appended = 0;
286
287 if (after == NULL) {
288
289
290
291
292
293 if (((ex->ex_flags & EXF_NOCOALESCE) == 0) &&
294 !LIST_EMPTY(&ex->ex_regions) &&
295 ((start + size) == LIST_FIRST(&ex->ex_regions)->er_start)) {
296
297
298
299 LIST_FIRST(&ex->ex_regions)->er_start = start;
300 extent_free_region_descriptor(ex, rp);
301 return;
302 }
303
304
305
306
307
308 rp->er_start = start;
309 rp->er_end = start + (size - 1);
310 LIST_INSERT_HEAD(&ex->ex_regions, rp, er_link);
311 return;
312 }
313
314
315
316
317 if (ex->ex_flags & EXF_NOCOALESCE)
318 goto cant_coalesce;
319
320
321
322
323 if ((after->er_end + 1) == start) {
324
325
326
327
328 after->er_end = start + (size - 1);
329 appended = 1;
330 }
331
332
333
334
335 if (LIST_NEXT(after, er_link) != NULL &&
336 ((start + size) == LIST_NEXT(after, er_link)->er_start)) {
337
338
339
340
341
342 if (appended) {
343
344
345
346 after->er_end = LIST_NEXT(after, er_link)->er_end;
347 nextr = LIST_NEXT(after, er_link);
348 LIST_REMOVE(nextr, er_link);
349 extent_free_region_descriptor(ex, nextr);
350 } else {
351
352
353
354 LIST_NEXT(after, er_link)->er_start = start;
355 }
356
357 extent_free_region_descriptor(ex, rp);
358 return;
359 }
360
361
362
363
364
365
366 if (appended) {
367 extent_free_region_descriptor(ex, rp);
368 return;
369 }
370
371 cant_coalesce:
372
373
374
375
376
377 rp->er_start = start;
378 rp->er_end = start + (size - 1);
379 LIST_INSERT_AFTER(after, rp, er_link);
380 }
381
382
383
384
385 int
386 extent_alloc_region(struct extent *ex, u_long start, u_long size, int flags)
387 {
388 struct extent_region *rp, *last, *myrp;
389 u_long end = start + (size - 1);
390 int error;
391
392 #ifdef DIAGNOSTIC
393
394 if (ex == NULL)
395 panic("extent_alloc_region: NULL extent");
396 if (size < 1) {
397 printf("extent_alloc_region: extent `%s', size 0x%lx\n",
398 ex->ex_name, size);
399 panic("extent_alloc_region: bad size");
400 }
401 if (end < start) {
402 printf(
403 "extent_alloc_region: extent `%s', start 0x%lx, size 0x%lx\n",
404 ex->ex_name, start, size);
405 panic("extent_alloc_region: overflow");
406 }
407 #endif
408
409
410
411
412
413 if ((start < ex->ex_start) || (end > ex->ex_end)) {
414 #ifdef DIAGNOSTIC
415 printf("extent_alloc_region: extent `%s' (0x%lx - 0x%lx)\n",
416 ex->ex_name, ex->ex_start, ex->ex_end);
417 printf("extent_alloc_region: start 0x%lx, end 0x%lx\n",
418 start, end);
419 panic("extent_alloc_region: region lies outside extent");
420 #else
421 return (EINVAL);
422 #endif
423 }
424
425
426
427
428
429 myrp = extent_alloc_region_descriptor(ex, flags);
430 if (myrp == NULL) {
431 #ifdef DIAGNOSTIC
432 printf(
433 "extent_alloc_region: can't allocate region descriptor\n");
434 #endif
435 return (ENOMEM);
436 }
437
438 alloc_start:
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453 last = NULL;
454
455 LIST_FOREACH(rp, &ex->ex_regions, er_link) {
456 if (rp->er_start > end) {
457
458
459
460
461 break;
462 }
463
464
465
466
467
468 if (rp->er_end >= start) {
469
470
471
472
473 if (flags & EX_WAITSPACE) {
474 ex->ex_flags |= EXF_WANTED;
475 error = tsleep(ex,
476 PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0),
477 "extnt", 0);
478 if (error)
479 return (error);
480 goto alloc_start;
481 }
482 extent_free_region_descriptor(ex, myrp);
483 return (EAGAIN);
484 }
485
486
487
488
489
490 last = rp;
491 }
492
493
494
495
496
497
498 extent_insert_and_optimize(ex, start, size, last, myrp);
499 return (0);
500 }
501
502
503
504
505
506 #define LE_OV(x, y, z) ((((x) + (y)) >= (x)) && (((x) + (y)) <= (z)))
507
508
509
510
511
512
513
514
515
516
517
518 int
519 extent_alloc_subregion(struct extent *ex, u_long substart, u_long subend,
520 u_long size, u_long alignment, u_long skew, u_long boundary, int flags,
521 u_long *result)
522 {
523 struct extent_region *rp, *myrp, *last, *bestlast;
524 u_long newstart, newend, exend, beststart, bestovh, ovh;
525 u_long dontcross;
526 int error;
527
528 #ifdef DIAGNOSTIC
529
530 if (ex == NULL)
531 panic("extent_alloc_subregion: NULL extent");
532 if (result == NULL)
533 panic("extent_alloc_subregion: NULL result pointer");
534 if ((substart < ex->ex_start) || (substart > ex->ex_end) ||
535 (subend > ex->ex_end) || (subend < ex->ex_start)) {
536 printf("extent_alloc_subregion: extent `%s', ex_start 0x%lx, ex_end 0x%lx\n",
537 ex->ex_name, ex->ex_start, ex->ex_end);
538 printf("extent_alloc_subregion: substart 0x%lx, subend 0x%lx\n",
539 substart, subend);
540 panic("extent_alloc_subregion: bad subregion");
541 }
542 if ((size < 1) || ((size - 1) > (subend - substart))) {
543 printf("extent_alloc_subregion: extent `%s', size 0x%lx\n",
544 ex->ex_name, size);
545 panic("extent_alloc_subregion: bad size");
546 }
547 if (alignment == 0)
548 panic("extent_alloc_subregion: bad alignment");
549 if (boundary && (boundary < size)) {
550 printf(
551 "extent_alloc_subregion: extent `%s', size 0x%lx, "
552 "boundary 0x%lx\n", ex->ex_name, size, boundary);
553 panic("extent_alloc_subregion: bad boundary");
554 }
555 #endif
556
557
558
559
560
561 myrp = extent_alloc_region_descriptor(ex, flags);
562 if (myrp == NULL) {
563 #ifdef DIAGNOSTIC
564 printf(
565 "extent_alloc_subregion: can't allocate region descriptor\n");
566 #endif
567 return (ENOMEM);
568 }
569
570 alloc_start:
571
572
573
574
575
576
577
578 last = NULL;
579
580
581
582
583
584
585
586
587
588
589
590
591 bestovh = 0;
592 beststart = 0;
593 bestlast = NULL;
594
595
596
597
598
599 exend = ex->ex_end;
600
601
602
603
604
605
606
607 newstart = extent_align(substart, alignment, skew);
608 if (newstart < ex->ex_start) {
609 #ifdef DIAGNOSTIC
610 printf(
611 "extent_alloc_subregion: extent `%s' (0x%lx - 0x%lx), alignment 0x%lx\n",
612 ex->ex_name, ex->ex_start, ex->ex_end, alignment);
613 panic("extent_alloc_subregion: overflow after alignment");
614 #else
615 extent_free_region_descriptor(ex, myrp);
616 return (EINVAL);
617 #endif
618 }
619
620
621
622
623
624
625 LIST_FOREACH(rp, &ex->ex_regions, er_link) {
626 if (rp->er_start >= newstart)
627 break;
628 last = rp;
629 }
630
631
632
633
634
635
636 if (last != NULL && last->er_end >= newstart)
637 newstart = extent_align((last->er_end + 1), alignment, skew);
638
639 for (; rp != LIST_END(&ex->ex_regions); rp = LIST_NEXT(rp, er_link)) {
640
641
642
643
644 if (rp->er_start > subend) {
645 exend = rp->er_start;
646 break;
647 }
648
649
650
651
652
653 if (LE_OV(newstart, size, rp->er_start)) {
654
655
656
657
658
659 if (boundary) {
660 newend = newstart + (size - 1);
661
662
663
664
665
666 dontcross = extent_align(newstart+1, boundary,
667 (flags & EX_BOUNDZERO) ? 0 : ex->ex_start)
668 - 1;
669
670 #if 0
671 printf("newstart=%lx newend=%lx ex_start=%lx ex_end=%lx boundary=%lx dontcross=%lx\n",
672 newstart, newend, ex->ex_start, ex->ex_end,
673 boundary, dontcross);
674 #endif
675
676
677 if (dontcross < ex->ex_start)
678 dontcross = ex->ex_end;
679 else if (newend > dontcross) {
680
681
682
683
684
685 newstart = dontcross + 1;
686 newend = newstart + (size - 1);
687 dontcross += boundary;
688 if (!LE_OV(newstart, size, rp->er_start))
689 goto skip;
690 }
691
692
693
694
695
696
697
698 if (newstart + size - 1 > ex->ex_end ||
699 dontcross < newstart)
700 goto fail;
701 }
702
703
704
705
706
707
708
709 ovh = rp->er_start - newstart - size;
710 if ((flags & EX_FAST) || (ovh == 0))
711 goto found;
712
713
714
715
716
717 if ((bestovh == 0) || (ovh < bestovh)) {
718 bestovh = ovh;
719 beststart = newstart;
720 bestlast = last;
721 }
722 }
723
724 skip:
725
726
727
728 newstart = extent_align((rp->er_end + 1), alignment, skew);
729 if (newstart < rp->er_end) {
730
731
732
733
734
735 goto fail;
736 }
737
738 last = rp;
739 }
740
741
742
743
744
745
746
747
748 if (LE_OV(newstart, (size - 1), subend)) {
749
750
751
752
753
754 if (boundary) {
755 newend = newstart + (size - 1);
756
757
758
759
760
761 dontcross = extent_align(newstart+1, boundary,
762 (flags & EX_BOUNDZERO) ? 0 : ex->ex_start)
763 - 1;
764
765 #if 0
766 printf("newstart=%lx newend=%lx ex_start=%lx ex_end=%lx boundary=%lx dontcross=%lx\n",
767 newstart, newend, ex->ex_start, ex->ex_end,
768 boundary, dontcross);
769 #endif
770
771
772 if (dontcross < ex->ex_start)
773 dontcross = ex->ex_end;
774 else if (newend > dontcross) {
775
776
777
778
779
780 newstart = dontcross + 1;
781 newend = newstart + (size - 1);
782 dontcross += boundary;
783 if (!LE_OV(newstart, (size - 1), subend))
784 goto fail;
785 }
786
787
788
789
790
791
792
793 if (newstart + size - 1 > ex->ex_end ||
794 dontcross < newstart)
795 goto fail;
796 }
797
798
799
800
801
802
803
804 ovh = exend - newstart - (size - 1);
805 if ((flags & EX_FAST) || (ovh == 0))
806 goto found;
807
808
809
810
811
812 if ((bestovh == 0) || (ovh < bestovh)) {
813 bestovh = ovh;
814 beststart = newstart;
815 bestlast = last;
816 }
817 }
818
819 fail:
820
821
822
823
824
825
826
827
828
829
830
831
832
833 if (((flags & EX_FAST) == 0) && (bestovh != 0)) {
834
835
836
837 newstart = beststart;
838 last = bestlast;
839 goto found;
840 }
841
842
843
844
845
846 if (flags & EX_WAITSPACE) {
847 ex->ex_flags |= EXF_WANTED;
848 error = tsleep(ex,
849 PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0), "extnt", 0);
850 if (error)
851 return (error);
852 goto alloc_start;
853 }
854
855 extent_free_region_descriptor(ex, myrp);
856 return (EAGAIN);
857
858 found:
859
860
861
862 extent_insert_and_optimize(ex, newstart, size, last, myrp);
863 *result = newstart;
864 return (0);
865 }
866
867 int
868 extent_free(struct extent *ex, u_long start, u_long size, int flags)
869 {
870 struct extent_region *rp, *nrp = NULL;
871 u_long end = start + (size - 1);
872 int exflags;
873
874 #ifdef DIAGNOSTIC
875
876 if (ex == NULL)
877 panic("extent_free: NULL extent");
878 if ((start < ex->ex_start) || (end > ex->ex_end)) {
879 extent_print(ex);
880 printf("extent_free: extent `%s', start 0x%lx, size 0x%lx\n",
881 ex->ex_name, start, size);
882 panic("extent_free: extent `%s', region not within extent",
883 ex->ex_name);
884 }
885
886 if (end < start) {
887 extent_print(ex);
888 printf("extent_free: extent `%s', start 0x%lx, size 0x%lx\n",
889 ex->ex_name, start, size);
890 panic("extent_free: overflow");
891 }
892 #endif
893
894
895
896
897
898
899
900
901 exflags = ex->ex_flags;
902
903 if ((exflags & EXF_NOCOALESCE) == 0) {
904
905 nrp = extent_alloc_region_descriptor(ex, flags);
906 if (nrp == NULL)
907 return (ENOMEM);
908 }
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928 LIST_FOREACH(rp, &ex->ex_regions, er_link) {
929
930
931
932
933
934 if (rp->er_end < start)
935 continue;
936
937
938
939
940
941
942
943 if (rp->er_start > end)
944 break;
945
946
947 if ((start == rp->er_start) && (end == rp->er_end)) {
948 LIST_REMOVE(rp, er_link);
949 extent_free_region_descriptor(ex, rp);
950 goto done;
951 }
952
953
954
955
956
957 if (ex->ex_flags & EXF_NOCOALESCE)
958 continue;
959
960
961 if ((start == rp->er_start) && (end < rp->er_end)) {
962 rp->er_start = (end + 1);
963 goto done;
964 }
965
966
967 if ((start > rp->er_start) && (end == rp->er_end)) {
968 rp->er_end = (start - 1);
969 goto done;
970 }
971
972
973 if ((start > rp->er_start) && (end < rp->er_end)) {
974
975 nrp->er_start = end + 1;
976 nrp->er_end = rp->er_end;
977
978
979 rp->er_end = start - 1;
980
981
982 LIST_INSERT_AFTER(rp, nrp, er_link);
983
984
985 nrp = NULL;
986 goto done;
987 }
988 }
989
990
991 #if defined(DIAGNOSTIC) || defined(DDB)
992 extent_print(ex);
993 #endif
994 printf("extent_free: start 0x%lx, end 0x%lx\n", start, end);
995 panic("extent_free: region not found");
996
997 done:
998 if (nrp != NULL)
999 extent_free_region_descriptor(ex, nrp);
1000 if (ex->ex_flags & EXF_WANTED) {
1001 ex->ex_flags &= ~EXF_WANTED;
1002 wakeup(ex);
1003 }
1004 return (0);
1005 }
1006
1007 static struct extent_region *
1008 extent_alloc_region_descriptor(struct extent *ex, int flags)
1009 {
1010 struct extent_region *rp;
1011 int s;
1012
1013 if (ex->ex_flags & EXF_FIXED) {
1014 struct extent_fixed *fex = (struct extent_fixed *)ex;
1015
1016 while (LIST_EMPTY(&fex->fex_freelist)) {
1017 if (flags & EX_MALLOCOK)
1018 goto alloc;
1019
1020 if ((flags & EX_WAITOK) == 0)
1021 return (NULL);
1022 ex->ex_flags |= EXF_FLWANTED;
1023 if (tsleep(&fex->fex_freelist,
1024 PRIBIO | ((flags & EX_CATCH) ? PCATCH : 0),
1025 "extnt", 0))
1026 return (NULL);
1027 }
1028 rp = LIST_FIRST(&fex->fex_freelist);
1029 LIST_REMOVE(rp, er_link);
1030
1031
1032
1033
1034
1035
1036
1037
1038 return (rp);
1039 }
1040
1041 alloc:
1042 s = splvm();
1043 rp = pool_get(&ex_region_pl, (flags & EX_WAITOK) ? PR_WAITOK : 0);
1044 splx(s);
1045 if (rp != NULL)
1046 rp->er_flags = ER_ALLOC;
1047
1048 return (rp);
1049 }
1050
1051 static void
1052 extent_free_region_descriptor(struct extent *ex, struct extent_region *rp)
1053 {
1054 int s;
1055
1056 if (ex->ex_flags & EXF_FIXED) {
1057 struct extent_fixed *fex = (struct extent_fixed *)ex;
1058
1059
1060
1061
1062
1063
1064 if (rp->er_flags & ER_ALLOC) {
1065 if (ex->ex_flags & EXF_FLWANTED) {
1066
1067 rp->er_flags = ER_ALLOC;
1068 LIST_INSERT_HEAD(&fex->fex_freelist, rp,
1069 er_link);
1070 goto wake_em_up;
1071 } else {
1072 s = splvm();
1073 pool_put(&ex_region_pl, rp);
1074 splx(s);
1075 }
1076 } else {
1077
1078 rp->er_flags = 0;
1079 LIST_INSERT_HEAD(&fex->fex_freelist, rp, er_link);
1080 }
1081
1082 if (ex->ex_flags & EXF_FLWANTED) {
1083 wake_em_up:
1084 ex->ex_flags &= ~EXF_FLWANTED;
1085 wakeup(&fex->fex_freelist);
1086 }
1087 return;
1088 }
1089
1090
1091
1092
1093 s = splvm();
1094 pool_put(&ex_region_pl, rp);
1095 splx(s);
1096 }
1097
1098 #ifndef DDB
1099 #define db_printf printf
1100 #endif
1101
1102 #if defined(DIAGNOSTIC) || defined(DDB) || !defined(_KERNEL)
1103 void
1104 extent_print(struct extent *ex)
1105 {
1106 struct extent_region *rp;
1107
1108 if (ex == NULL)
1109 panic("extent_print: NULL extent");
1110
1111 #ifdef _KERNEL
1112 db_printf("extent `%s' (0x%lx - 0x%lx), flags=%b\n", ex->ex_name,
1113 ex->ex_start, ex->ex_end, ex->ex_flags, EXF_BITS);
1114 #else
1115 db_printf("extent `%s' (0x%lx - 0x%lx), flags = 0x%x\n", ex->ex_name,
1116 ex->ex_start, ex->ex_end, ex->ex_flags);
1117 #endif
1118
1119 LIST_FOREACH(rp, &ex->ex_regions, er_link)
1120 db_printf(" 0x%lx - 0x%lx\n", rp->er_start, rp->er_end);
1121 }
1122 #endif