From nobody Sun Feb 13 13:07:15 2022 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 8E2E719BC748; Sun, 13 Feb 2022 13:07:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JxSLW2vgvz3J5y; Sun, 13 Feb 2022 13:07:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644757635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o3/oTVy06cfcgkREIQb8Yzf6QZDglJOTdJNutw7GCLw=; b=LxSMZJdDoW2vUfc9n9/GFK2e+KSvvjqrGogZ0DJ5aNy6Yf9X8dLPa9GfmsnZ3xKg/Ryxsx FMpT9h2TF0V0V5izcQ7/7obH+McqlHwD2x8Xb5rREmRSco8J+x6m3fsPIWZius1ao3AoWi 5LuXK9r4poMtovFTjGAbSPaqYRe8Mxwk/zOTsvJiukvJ25xdnAH3njg8jaaVeeIlUGxwQI KZy/7oRcIus8BsfYLo9TyFHrLQyupKfw5jCUyeBpDjSOfEQNRyJBzjccmLzhCbmPftBqvU J/4EqIUoxfWbg2yQsNe4l12uqaVO9PsUKaP07+/MBv/Ek6nLh+t+fu6pw9rLeA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 424E21BAB0; Sun, 13 Feb 2022 13:07:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 21DD7FEl073936; Sun, 13 Feb 2022 13:07:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 21DD7FfC073935; Sun, 13 Feb 2022 13:07:15 GMT (envelope-from git) Date: Sun, 13 Feb 2022 13:07:15 GMT Message-Id: <202202131307.21DD7FfC073935@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Mateusz Guzik Subject: git: b53133a7789b - main - proc: load/store p_cowgen using atomic primitives List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mjg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: b53133a7789b2cf17944a16248fbad4e75e6b432 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1644757635; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=o3/oTVy06cfcgkREIQb8Yzf6QZDglJOTdJNutw7GCLw=; b=I17Ss0VjIv/4AevzwSGbaw+sZRHE4e0BKFvZjP4TnxcH2yFVVyd71jIBOqPFxMUyn2nb5L kI9TFCoLD1XhyIOcNpZ5+WnCRwu0FfN6y7+o9uY2eDwOwAU4Be1pSYRTYm6k3dKbhINhM+ NVkaIy6yM+5mKxEoFufMouYdJVk+VLwGm1l3j8UeBjk0T1TNacTjw+iC8SMO3GKc6dcgl7 N4j8iz9up9qeN8TWr90OguD4s+jv38eoibgjcNA/x/6Fb5DegLfHQW0fTXYgSNs6OJaCwZ E33vj4kjAN57WcZVGcvUylry2pKdI6Jwnb9zVzGznaDkbcVJ9Nobfo7XU8irTA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1644757635; a=rsa-sha256; cv=none; b=gNTNNCrSk6rMIzq1KbO3AmZjv6R4VKc56i7HvvoEu7VfjO1nWWUZlwmI2Tbl1mCEmDnB9l k1Epwcdqswy8YSgaFYC3UC3L5Xs84y5iGe9XRlm/UfZJTRqZ1zWK6SjAFzgd8kLlC4Wdjo 4NYRpQ5F8dPQeDuMuqTl102fzZiW+btMJTrq0tOO4oqIM5pPDf0MzkTgJYVRQszVs1RVUp W41F1pLKVm4a0KulAKyAW7b39AuLcVNrDxW+ZqeXPppUScVHYawRdZtkp4VGp6svDrUkQK jCA01x4iPF1weJHsDDpL+YIomBcZmE5UapRs3jwXAf7Djcb/u+HUwtJnvUhHUA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by mjg: URL: https://cgit.FreeBSD.org/src/commit/?id=b53133a7789b2cf17944a16248fbad4e75e6b432 commit b53133a7789b2cf17944a16248fbad4e75e6b432 Author: Mateusz Guzik AuthorDate: 2022-02-12 19:33:34 +0000 Commit: Mateusz Guzik CommitDate: 2022-02-13 13:07:08 +0000 proc: load/store p_cowgen using atomic primitives --- sys/amd64/amd64/trap.c | 2 +- sys/arm/arm/trap-v6.c | 2 +- sys/i386/i386/trap.c | 2 +- sys/kern/subr_syscall.c | 2 +- sys/kern/subr_trap.c | 2 +- sys/powerpc/powerpc/trap.c | 2 +- sys/sys/proc.h | 5 +++-- 7 files changed, 9 insertions(+), 8 deletions(-) diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index ff4bccebed5b..8d8bdd6fbb6e 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -309,7 +309,7 @@ trap(struct trapframe *frame) td->td_pticks = 0; td->td_frame = frame; addr = frame->tf_rip; - if (td->td_cowgen != p->p_cowgen) + if (td->td_cowgen != atomic_load_int(&p->p_cowgen)) thread_cow_update(td); switch (type) { diff --git a/sys/arm/arm/trap-v6.c b/sys/arm/arm/trap-v6.c index 7bd5780af338..13eca6efb9bf 100644 --- a/sys/arm/arm/trap-v6.c +++ b/sys/arm/arm/trap-v6.c @@ -418,7 +418,7 @@ abort_handler(struct trapframe *tf, int prefetch) p = td->td_proc; if (usermode) { td->td_pticks = 0; - if (td->td_cowgen != p->p_cowgen) + if (td->td_cowgen != atomic_load_int(&p->p_cowgen)) thread_cow_update(td); } diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index d770cf808f5f..9da5a177906c 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -301,7 +301,7 @@ trap(struct trapframe *frame) td->td_pticks = 0; td->td_frame = frame; addr = frame->tf_eip; - if (td->td_cowgen != p->p_cowgen) + if (td->td_cowgen != atomic_load_int(&p->p_cowgen)) thread_cow_update(td); switch (type) { diff --git a/sys/kern/subr_syscall.c b/sys/kern/subr_syscall.c index fa5dcb482f2c..33dd50d3d50a 100644 --- a/sys/kern/subr_syscall.c +++ b/sys/kern/subr_syscall.c @@ -68,7 +68,7 @@ syscallenter(struct thread *td) sa = &td->td_sa; td->td_pticks = 0; - if (__predict_false(td->td_cowgen != p->p_cowgen)) + if (__predict_false(td->td_cowgen != atomic_load_int(&p->p_cowgen))) thread_cow_update(td); traced = (p->p_flag & P_TRACED) != 0; if (__predict_false(traced || td->td_dbgflags & TDB_USERWR)) { diff --git a/sys/kern/subr_trap.c b/sys/kern/subr_trap.c index ec8f686a497d..52559c162249 100644 --- a/sys/kern/subr_trap.c +++ b/sys/kern/subr_trap.c @@ -247,7 +247,7 @@ ast(struct trapframe *framep) thread_unlock(td); VM_CNT_INC(v_trap); - if (td->td_cowgen != p->p_cowgen) + if (td->td_cowgen != atomic_load_int(&p->p_cowgen)) thread_cow_update(td); if (td->td_pflags & TDP_OWEUPC && p->p_flag & P_PROFIL) { addupc_task(td, td->td_profil_addr, td->td_profil_ticks); diff --git a/sys/powerpc/powerpc/trap.c b/sys/powerpc/powerpc/trap.c index ab5189a0f418..3fb1badd7ba8 100644 --- a/sys/powerpc/powerpc/trap.c +++ b/sys/powerpc/powerpc/trap.c @@ -254,7 +254,7 @@ trap(struct trapframe *frame) td->td_pticks = 0; td->td_frame = frame; addr = frame->srr0; - if (td->td_cowgen != p->p_cowgen) + if (td->td_cowgen != atomic_load_int(&p->p_cowgen)) thread_cow_update(td); /* User Mode Traps */ diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 0e33192303f4..71105239e40e 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1005,8 +1005,9 @@ extern pid_t pid_max; } while (0) #define PROC_UPDATE_COW(p) do { \ - PROC_LOCK_ASSERT((p), MA_OWNED); \ - (p)->p_cowgen++; \ + struct proc *_p = (p); \ + PROC_LOCK_ASSERT((_p), MA_OWNED); \ + atomic_store_int(&_p->p_cowgen, _p->p_cowgen + 1); \ } while (0) #define PROC_COW_CHANGECOUNT(td, p) ({ \