From owner-freebsd-mips@FreeBSD.ORG Fri Aug 10 11:57:52 2012 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 73B11106566C for ; Fri, 10 Aug 2012 11:57:52 +0000 (UTC) (envelope-from ambrosehua@gmail.com) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id E88DB8FC0A for ; Fri, 10 Aug 2012 11:57:51 +0000 (UTC) Received: by wgbds11 with SMTP id ds11so1249246wgb.31 for ; Fri, 10 Aug 2012 04:57:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=FOKHL5EPgs/XNLLY8H7g7ZT2HarIgaKhzAhgIrrUDmU=; b=skaJsp0d41S9/kaYNbirYdvA2RSepTzS4eh04YoGitXVkVDbWIIgEYYHAXTTVfGwxM mzRJ6DSLvekK/vBIpaVPPdOx6Uv0lDXseqQr+/GhDpnIrd/cIUcC6W7AW39cEdwAQZJQ AOX046L/Za6Q/y9I/7t4ZeDdfY2zDaW7d7Yuzl4TPKr8zv9p9DawtWtcYQkKu10Yv27F amneU0hbDniitqlHmup7nqB/p+R33Qvz1MF0TUoZ+4orgUwwLeVrXz3qjvPM/p0UCxzd Wm41AfV5sNmgRiKszjPa4HUX9UjmZPKBA8M+5BhcYeytwAUCDiZUIOqZOn9ZEGzHO5Ox 2ZmA== MIME-Version: 1.0 Received: by 10.216.55.195 with SMTP id k45mr1371184wec.216.1344599870606; Fri, 10 Aug 2012 04:57:50 -0700 (PDT) Received: by 10.223.83.9 with HTTP; Fri, 10 Aug 2012 04:57:50 -0700 (PDT) Date: Fri, 10 Aug 2012 19:57:50 +0800 Message-ID: From: Paul Ambrose To: freebsd-mips@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Subject: tlb.c tlb_invalidate_all_user simplified X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Aug 2012 11:57:52 -0000 when I saw this commit, commit e60abd7cb37fb1b66e8b0c48050aa56732c73e90 Author: alc Date: Fri Aug 10 05:00:50 2012 +0000 Merge r134393 from amd64/i386: The machine-independent parts of the virtual memory system always pass a valid pmap to the pmap functions that require one. Remove the checks for NULL. (These checks have their origins in the Mach pmap.c that was integrated into BSD. None of the new code written specifically for FreeBSD included them.) according to the description here, pmap should not be null, I think tlb_invalidate_all_user(struct pmap * pmap), in mips/mips/tlb.c ---------------------------------------------------------------------------------------------------- tlb_invalidate_all_user(struct pmap *pmap) { register_t asid; register_t s; unsigned i; s = intr_disable(); asid = mips_rd_entryhi() & TLBHI_ASID_MASK; for (i = mips_rd_wired(); i < num_tlbentries; i++) { register_t uasid; mips_wr_index(i); tlb_read(); uasid = mips_rd_entryhi() & TLBHI_ASID_MASK; if (pmap == NULL) { /* * Invalidate all non-kernel entries. */ if (uasid == 0) continue; } else { /* * Invalidate this pmap's entries. */ if (uasid != pmap_asid(pmap)) continue; } tlb_invalidate_one(i); } mips_wr_entryhi(asid); intr_restore(s); } --------------------------------------------------------------------------- could be simplified like this: --------------------------------------------------------------------------- tlb_invalidate_all_user(struct pmap *pmap) { register_t asid; register_t s; unsigned i; s = intr_disable(); asid = mips_rd_entryhi() & TLBHI_ASID_MASK; for (i = mips_rd_wired(); i < num_tlbentries; i++) { register_t uasid; mips_wr_index(i); tlb_read(); uasid = mips_rd_entryhi() & TLBHI_ASID_MASK; if ((uasid != pmap_asid(pmap)) || (uasid == 0)) continue; tlb_invalidate_one(i); } mips_wr_entryhi(asid); intr_restore(s); } funcntion tlb_invalidate_all_user(struct pmap *pmap) is ONLY called like this: pmap_activate -> pmap_alloc_asid -> tlb_invalidate_all_user, I think the pmap passed fullfils the assumption. How do you like it ?