From patchwork Thu Jun 28 23:59:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Brodkin X-Patchwork-Id: 936556 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="r2q6+sxu"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="ADThAW/d"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41GxbF0PGLz9s0n for ; Fri, 29 Jun 2018 09:59:37 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=jVqewhbIlkU6iOpy1M1H064qiPXVKU3E5jhJevWH41c=; b=r2q 6+sxu89ao7ZIdOZC8BiTEm6o0qSkD43sYFrfjNnlRxSzk8t1vzyTyGnIXg/6dNAoIISIzDU/RVMz0 ZpfZ7R63miroPG02rlarH3cmC43ubm2H2KkB0sWM1PsNtvxqMoMv10jFBpMJUuGQOmwxp1OzXg6zf UJL4WnGHjpgcfeMgbUe1FfG01Xnw/Bf4AZHFQPGZZtyMnj6Fyr7s5SmiaJAMFQBJX1aApOtNRTSDi oFu2OmB+M0glO5GyyW0c8E3ODZ7O/TCH+ebTOTlE6yhj1RDAfpi0wb7zDt+IqWgND12JxJ8hFKKiX No8kdq/6ed9wXV8fIpdXzyau0ivvP3g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYgp4-0000Wx-Rf; Thu, 28 Jun 2018 23:59:34 +0000 Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fYgp1-0000W0-Es for linux-snps-arc@lists.infradead.org; Thu, 28 Jun 2018 23:59:33 +0000 Received: from mailhost.synopsys.com (mailhost2.synopsys.com [10.13.184.66]) by smtprelay.synopsys.com (Postfix) with ESMTP id 305C010C0745; Thu, 28 Jun 2018 16:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1530230358; bh=wB5LVDlsvaiC+I7+qgEpinI6T53E3Fc+ibflRQIKlEc=; h=From:To:Cc:Subject:Date:From; b=ADThAW/dZlIHXNFioMBrrr3+RXgivvYAjTiydakOy7QwHatx/EF3EHNDlslOv884j zOxDuypr2jGbC6SgDE27drFR1M8QYNworU208Epzb2hlzx+OGHdOcrTEwBYQap0F1R PL4+BfiqAuRUrviXQveh3yQo/T8xQkRCEklsgyo1VaBz2ZM2hAAe+PP/cUERNDQClI p4ncaUKCXSABupRV7V5X2GwrGTMqPF3W0z2MfWGSzg65tfuPN0W9ISAtZo+pXMrTqW dWlo3JMjzemxFIB1J73hjxmGyKPbISjpAxRuZmbOlJsZIt7HxRWSaAjSiJDoRSObLG yFk+WvgDOqx1w== Received: from abrodkin-7480l.internal.synopsys.com (abrodkin-7480l.internal.synopsys.com [10.9.128.133]) by mailhost.synopsys.com (Postfix) with ESMTP id 14F003D3F; Thu, 28 Jun 2018 16:59:18 -0700 (PDT) From: Alexey Brodkin To: linux-snps-arc@lists.infradead.org Subject: [PATCH] ARC: Fix __swp_offset() implementation Date: Thu, 28 Jun 2018 16:59:14 -0700 Message-Id: <20180628235914.20706-1-abrodkin@synopsys.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180628_165931_510528_22A67AA2 X-CRM114-Status: GOOD ( 10.83 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org, stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org We encode offset from swapcache page in __swp_entry() this way, see [1]: | /* Encode swap {type,off} tuple into PTE | * We reserve 13 bits for 5-bit @type, keeping bits 12-5 zero, ensuring that | * PAGE_PRESENT is zero in a PTE holding swap "identifier" | */ | #define __swp_entry(type, off) ((swp_entry_t) { \ | ((type) & 0x1f) | ((off) << 13) }) But decode in __swp_offset() as: | #define __swp_offset(pte_lookalike) ((pte_lookalike).val << 13) which is obviously wrong, we should ">> 13" instead. This basically fixes swap usage on ARC finally. | # mkswap /dev/sda2 | | # swapon -a -e /dev/sda2 | Adding 500728k swap on /dev/sda2. Priority:-2 extents:1 across:500728k | | # free | total used free shared buffers cached | Mem: 765104 13456 751648 4736 8 4736 | -/+ buffers/cache: 8712 756392 | Swap: 500728 0 500728 [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/arc/include/asm/pgtable.h#n375 Signed-off-by: Alexey Brodkin Cc: stable@vger.kernel.org --- arch/arc/include/asm/pgtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arc/include/asm/pgtable.h b/arch/arc/include/asm/pgtable.h index 08fe33830d4b..77676e18da69 100644 --- a/arch/arc/include/asm/pgtable.h +++ b/arch/arc/include/asm/pgtable.h @@ -379,7 +379,7 @@ void update_mmu_cache(struct vm_area_struct *vma, unsigned long address, /* Decode a PTE containing swap "identifier "into constituents */ #define __swp_type(pte_lookalike) (((pte_lookalike).val) & 0x1f) -#define __swp_offset(pte_lookalike) ((pte_lookalike).val << 13) +#define __swp_offset(pte_lookalike) ((pte_lookalike).val >> 13) /* NOPs, to keep generic kernel happy */ #define __pte_to_swp_entry(pte) ((swp_entry_t) { pte_val(pte) })