Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp2179396ybx; Fri, 8 Nov 2019 00:54:03 -0800 (PST) X-Google-Smtp-Source: APXvYqxAbKthAr5QFRINhI2APLHbM2yF4D//FZnoxESELzh4eGxe13cb9UqYqY5ewPYJxAgdQSd8 X-Received: by 2002:a17:906:b2c7:: with SMTP id cf7mr544874ejb.218.1573203243012; Fri, 08 Nov 2019 00:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573203243; cv=none; d=google.com; s=arc-20160816; b=YBkIVEd/iOQ3FoMz/JaURQV0tosOF0IjGqLa97UhdnbsidUZUTxRcTYrjYtgXJRNIT axRwNurM/yOZSgWhc403Qz1iBIatq7BfK/DJO44FnuPGTlVx0AMSESP+4l6MnAewXjZw u6I418imEj1J3isXxLH6ywT6r5NKgDrYwdIKSKjtMq82IFX6UWfEiCw0YSwMnG1qS23X GhCF0Az1lLkLCpkTb3vPENrVA/S/RRUkj1Viem0ElZWufW3NRjuUgzMuJLhYCdDUM1lp HB04C85nbIeNxUWlkj/rFvagZkllLEmGW4dRGKArd3aNT2CLQtlU9rcb9a1yA957TRmE ppnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=S85cv+dFRN5SsgvHSORQbdSIxYwn0oEGmdvNGbJesco=; b=jZ/dTCKYOoKwOx8pYTr16FvJ4bnBdsMIzaSn7YQw5zmTn1ohNXXqu/55H8Qrs3zpaN NkXuO7ooStX0ZRkn/+hTliM34FVRNH/ndFY4TsofEgKdtk8y7Y4CjLgK3tFyfehXb52s kmsL4WFSNAV5SCeAfgqqsCLmf5PbEybXh9Ujxr5BUwJOEVnSfvoFGEjFWi6PWW9RhWXa ays4YqDogdFaFOm8NTa/OdpENA/lv1+FwXwnMbJHcNOw0Ln9OeJuhvGOxUnGiBiahlkG Z/9nq+IyZutfnmjBlgx5lA4dF6tvkP/WGWJCxOO89ST8/A4apFqKNNPbfDbwc+zhn9ha xylQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="T4/hkniH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si2516227eju.398.2019.11.08.00.53.38; Fri, 08 Nov 2019 00:54:02 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b="T4/hkniH"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730260AbfKHIu4 (ORCPT + 99 others); Fri, 8 Nov 2019 03:50:56 -0500 Received: from mail-ot1-f65.google.com ([209.85.210.65]:38898 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725975AbfKHIu4 (ORCPT ); Fri, 8 Nov 2019 03:50:56 -0500 Received: by mail-ot1-f65.google.com with SMTP id v24so4576084otp.5 for ; Fri, 08 Nov 2019 00:50:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=S85cv+dFRN5SsgvHSORQbdSIxYwn0oEGmdvNGbJesco=; b=T4/hkniHISxhKLviDVpNOrLIS3abyDnRgQR27nInQ39mJfNwJk6aSi5flcSy0a8nff 3EVQJqEWux4tnPaNvTFjGU804fkSgk03TkvJIB91ggXPxGE/QseehJlvvX3Wdh6LZwjp 1+s29e2NxGZKY/UG6nJYehPsF14x3szH0Mc2OGM37sGXTYhBlQcBo9W6F1NLNYH+YRXk 4aNgnF7AL3sbmok1Mh3XwPia/IoVoiPw/0g9GsSVOW7NaC/Psni09+17MkYXZWKAiDUv GkR2xO3Ivjq9DY8E6c/kirvfYFyu0j5XZmUyO3abzIhBmN5WSAa3e2eNqgXn1LoTnLsg 2kEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=S85cv+dFRN5SsgvHSORQbdSIxYwn0oEGmdvNGbJesco=; b=fYK4kueNXChZtZaDr6PQ/SD4gYfyl37gReKHGTfpT7YIrsmeZ2YNIvGTIohF7C/1Z0 ia0LxG94G4rwCu+TOhwLUacgnhTrRw/ObpIWk7U6e6/zdsBflXi2fPzZUiwlk0gH/SZX yIPp6HrZyNI74KwLGNC7TQyLONLYOhM5TgkNvwZBvkxIJ1IaycNf/bg3/TbPcmy7Zw82 nfvgLsN0hF1lTtVlfNnXT7uS6i0ntLc+facBG0eIkPVw62IKLiRaMER8bD9bfqsUL8yV T4OZZwrxIJjCwz6wUAA1UWaNBYh+Wqx7bcfEz10aM4cCxY2A2nFDvERsqbtZzDDPz6Vr 5K2A== X-Gm-Message-State: APjAAAWGj+RRGvUzEAXOSDB9rLwvr9WawaYThiiBjcdJq6ul4sfMnGXU XdYLXJLt0b7edQm1t4o0Y0qMcWOPPev7QHPPqPksQw== X-Received: by 2002:a05:6830:2106:: with SMTP id i6mr2362173otc.75.1573203055439; Fri, 08 Nov 2019 00:50:55 -0800 (PST) MIME-Version: 1.0 References: <1572920412-15661-1-git-send-email-zong.li@sifive.com> <20191108072523.GA20338@infradead.org> In-Reply-To: <20191108072523.GA20338@infradead.org> From: Zong Li Date: Fri, 8 Nov 2019 16:50:44 +0800 Message-ID: Subject: Re: [PATCH v2] riscv: Use PMD_SIZE to repalce PTE_PARENT_SIZE To: Christoph Hellwig Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org, Paul Walmsley , Palmer Dabbelt , Anup Patel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 8, 2019 at 3:25 PM Christoph Hellwig wrote: > > On Mon, Nov 04, 2019 at 06:20:12PM -0800, Zong Li wrote: > > uintptr_t map_size = PAGE_SIZE; > > > > - /* Upgrade to PMD/PGDIR mappings whenever possible */ > > - if (!(base & (PTE_PARENT_SIZE - 1)) && > > - !(size & (PTE_PARENT_SIZE - 1))) > > - map_size = PTE_PARENT_SIZE; > > + /* Upgrade to PMD_SIZE mappings whenever possible */ > > + if (!(base & (PMD_SIZE - 1)) && > > + !(size & (PMD_SIZE - 1))) > > + map_size = PMD_SIZE; > > The check easily fits onto a single line now. Also the map_size > variable is rather pointless. Why not: > > if ((base & (PMD_SIZE - 1) || (size & (PMD_SIZE - 1))) > return PAGE_SIZE; > return PMD_SIZE; Yes, Use positive representation is more clear to me. Change it in next version.