Deleted Added
full compact
kern_thread.c (285387) kern_thread.c (285633)
1/*-
2 * Copyright (C) 2001 Julian Elischer <julian@freebsd.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 * DAMAGE.
27 */
28
29#include "opt_witness.h"
30#include "opt_hwpmc_hooks.h"
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (C) 2001 Julian Elischer <julian@freebsd.org>.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
26 * DAMAGE.
27 */
28
29#include "opt_witness.h"
30#include "opt_hwpmc_hooks.h"
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 285387 2015-07-11 15:21:37Z adrian $");
33__FBSDID("$FreeBSD: head/sys/kern/kern_thread.c 285633 2015-07-16 14:30:11Z mjg $");
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/mutex.h>
40#include <sys/proc.h>
41#include <sys/rangelock.h>

--- 362 unchanged lines hidden (view full) ---

404 newtd->td_limit = lim_hold(td->td_limit);
405 newtd->td_cowgen = td->td_cowgen;
406}
407
408void
409thread_cow_free(struct thread *td)
410{
411
34
35#include <sys/param.h>
36#include <sys/systm.h>
37#include <sys/kernel.h>
38#include <sys/lock.h>
39#include <sys/mutex.h>
40#include <sys/proc.h>
41#include <sys/rangelock.h>

--- 362 unchanged lines hidden (view full) ---

404 newtd->td_limit = lim_hold(td->td_limit);
405 newtd->td_cowgen = td->td_cowgen;
406}
407
408void
409thread_cow_free(struct thread *td)
410{
411
412 if (td->td_ucred)
412 if (td->td_ucred != NULL)
413 crfree(td->td_ucred);
413 crfree(td->td_ucred);
414 if (td->td_limit)
414 if (td->td_limit != NULL)
415 lim_free(td->td_limit);
416}
417
418void
419thread_cow_update(struct thread *td)
420{
421 struct proc *p;
415 lim_free(td->td_limit);
416}
417
418void
419thread_cow_update(struct thread *td)
420{
421 struct proc *p;
422 struct ucred *oldcred;
423 struct plimit *oldlimit;
422
423 p = td->td_proc;
424
425 p = td->td_proc;
426 oldcred = NULL;
427 oldlimit = NULL;
424 PROC_LOCK(p);
428 PROC_LOCK(p);
425 if (td->td_ucred != p->p_ucred)
426 cred_update_thread(td);
427 if (td->td_limit != p->p_limit)
428 lim_update_thread(td);
429 if (td->td_ucred != p->p_ucred) {
430 oldcred = td->td_ucred;
431 td->td_ucred = crhold(p->p_ucred);
432 }
433 if (td->td_limit != p->p_limit) {
434 oldlimit = td->td_limit;
435 td->td_limit = lim_hold(p->p_limit);
436 }
429 td->td_cowgen = p->p_cowgen;
430 PROC_UNLOCK(p);
437 td->td_cowgen = p->p_cowgen;
438 PROC_UNLOCK(p);
439 if (oldcred != NULL)
440 crfree(oldcred);
441 if (oldlimit != NULL)
442 lim_free(oldlimit);
431}
432
433/*
434 * Discard the current thread and exit from its context.
435 * Always called with scheduler locked.
436 *
437 * Because we can't free a thread while we're operating under its context,
438 * push the current thread into our CPU's deadthread holder. This means

--- 760 unchanged lines hidden ---
443}
444
445/*
446 * Discard the current thread and exit from its context.
447 * Always called with scheduler locked.
448 *
449 * Because we can't free a thread while we're operating under its context,
450 * push the current thread into our CPU's deadthread holder. This means

--- 760 unchanged lines hidden ---