2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include "afs/param.h"
14 #include "afs/sysincludes.h" /* Standard vendor system headers */
15 #include "afsincludes.h" /* Afs-based standard headers */
16 #include "afs/afs_stats.h" /* afs statistics */
20 /* afs_osi_TraverseProcTable() - Walk through the systems process
21 * table, calling afs_GCPAGs_perproc_func() for each process.
26 * NOTE: h/proc_private.h gives the process table locking rules
27 * It indicates that access to p_cred must be protected by
29 * mp_mtproc_unlock(p);
31 * The code in sys/pm_prot.c uses pcred_lock() to protect access to
32 * the process creds, and uses mp_mtproc_lock() only for audit-related
33 * changes. To be safe, we use both.
37 afs_osi_TraverseProcTable(void)
42 MP_SPINLOCK(activeproc_lock
);
43 MP_SPINLOCK(sched_lock
);
47 * Instead of iterating through all of proc[], traverse only
48 * the list of active processes. As an example of this,
49 * see foreach_process() in sys/vm_sched.c.
51 * We hold the locks for the entire scan in order to get a
52 * consistent view of the current set of creds.
55 for (p
= proc
; endchain
== 0; p
= &proc
[p
->p_fandx
]) {
56 if (p
->p_fandx
== 0) {
64 afs_GCPAGs_perproc_func(p
);
69 MP_SPINUNLOCK(sched_lock
);
70 MP_SPINUNLOCK(activeproc_lock
);
73 /* return a pointer (sometimes a static copy ) to the cred for a
75 * subsequent calls may overwrite the previously returned value.
78 afs_osi_proc2cred(afs_proc_t
* p
)
84 * Cannot use afs_warnuser() here, as the code path
85 * eventually wants to grab sched_lock, which is
92 #endif /* AFS_GCPAGS */