Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp272780imm; Wed, 4 Jul 2018 23:29:25 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdsZH+01gFZel0A61ytKqdOCWuQ5H2eHiN/U54I1oT10sildnldZ7xh+JUzbf7vswmn3ae5 X-Received: by 2002:a65:468e:: with SMTP id h14-v6mr4241940pgr.89.1530772165385; Wed, 04 Jul 2018 23:29:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530772165; cv=none; d=google.com; s=arc-20160816; b=ToJx+BJc457K5R4sgcvHlSSXGEeOaOyZZu4p6K4J4TPrvhTY0AZYv0ru6LYkNS0XDv 2pqGV1BtBnpHBidjYrML5jvbqnhMSHfLOAU6RgXJFQ+8jRO5gJe5Pastm5KvqDzG8qzc KNTj9Af4pgPTrnGzusIrRplBk1pKHHsBV7iO+IFvLyDrbqKUOW8HAIbAeZO0IAE+D7uv oMJvZtBuPlYS2ciK7NBZ3wBdd9aqa6Wur8HtbccjFPAY9eRH2z0fqM4xy0Q4GDMN0Nhk DQUsIwf3TZw7tqicWbJAMlPEzke/MR4Af2QaVtNA+8MtN70ogL+tWbf+UocdJy6nFM3M Y6OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=uL0IjIGzGO52M5fIIX0UzDY54j0wN3DZwLeElhgRpG0=; b=GJHYP4a1LW5VGirvYcgnOFW3eUjgXzfYRUSRy7z/7YEfEhK5Nh8kLbnKvbB3cDL/d8 GpXjA9n4pbkAi9w7oEP4tQ6eNpPavWpvm2CwNAYyRkHpwGUi8BbC0o1yfvQbDNC231lu iNFEfH/8r7CieicHgvn7kIZdv7maRmybTq/NVfgg3ij0PBKiuV6WWVEBpzKHZLDugFLU YXd4RoiOY0gHt4K0FgNzDdNtAH5tQmSgZI0IKPV1VkFoSNkzrwcnAoDGEZ/yT4UH0GT9 Sw3AAn4k07YxfXdi9UZX5efRW/cLnkSkrNGhMA18MnIbCmRBRPFgYj2lalKQcx9NnrAF Mqqw== ARC-Authentication-Results: i=1; mx.google.com; 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 x69-v6si5685577pfe.318.2018.07.04.23.29.11; Wed, 04 Jul 2018 23:29:25 -0700 (PDT) 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; 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 S1753120AbeGEG2b (ORCPT + 99 others); Thu, 5 Jul 2018 02:28:31 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:49203 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750884AbeGEG2a (ORCPT ); Thu, 5 Jul 2018 02:28:30 -0400 Received: from p4fea482e.dip0.t-ipconnect.de ([79.234.72.46] helo=nanos.glx-home) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1faxkd-0003yC-LG; Thu, 05 Jul 2018 08:28:23 +0200 Date: Thu, 5 Jul 2018 08:28:23 +0200 (CEST) From: Thomas Gleixner To: Bin Yang cc: mingo@redhat.com, hpa@zytor.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] x86/mm: fix cpu stuck issue in __change_page_attr_set_clr In-Reply-To: <1530769636-26603-1-git-send-email-bin.yang@intel.com> Message-ID: References: <1530769636-26603-1-git-send-email-bin.yang@intel.com> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 5 Jul 2018, Bin Yang wrote: > static inline pgprot_t static_protections(pgprot_t prot, unsigned long address, > - unsigned long pfn) > + unsigned long pfn, unsigned long *page_num) > { > pgprot_t forbidden = __pgprot(0); > + unsigned long tmp; > + unsigned long num = PUD_PAGE_SIZE >> PAGE_SHIFT; Everything is a PUD? Oh well, you clearly made a lot of effort to understand the code you are changing. > /* > * The BIOS area between 640k and 1Mb needs to be executable for > * PCI BIOS based config access (CONFIG_PCI_GOBIOS) support. > */ > #ifdef CONFIG_PCI_BIOS > - if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT)) > - pgprot_val(forbidden) |= _PAGE_NX; > + if (pcibios_enabled) { > + tmp = (BIOS_BEGIN >> PAGE_SHIFT) > pfn ? > + (BIOS_BEGIN >> PAGE_SHIFT) - pfn : ULONG_MAX; > + if (within(pfn, BIOS_BEGIN >> PAGE_SHIFT, > + BIOS_END >> PAGE_SHIFT)) { > + pgprot_val(forbidden) |= _PAGE_NX; > + tmp = (BIOS_END >> PAGE_SHIFT) - pfn; > + } > + num = num > tmp ? tmp : num; What? I really gave you a hint which used a overlaps() helper in the pseudo code. But sure open coding the same thing in 5 places is faster, right? You managed to make this code completely unreadable and I'm not even trying to review that mess. > + for (i = 0; i < (psize >> PAGE_SHIFT); > + i += pnum, addr += PAGE_SIZE * pnum, pfn += pnum) { > + pgprot_t chk_prot = > + static_protections(req_prot, addr, pfn, &pnum); When done right, then there is no need for a loop at all. And I told you so. But that would need more effort than creating a trainwreck, right? Stop sending half baken and half thought out patches. I really spent a lot of time explaining you things in detail and giving you hints how it should be done. Feel free to ignore me, but don't be surprised if I'm ignoring you as well. Thanks, tglx