Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp232543imm; Wed, 4 Jul 2018 22:32:33 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf0JyDIzphvEaEJN4nFVpGvkqSC9ANPx1TiQ87YJoNIGILFT6ho4+UJCDZmoOK7BZR9iTsx X-Received: by 2002:a17:902:8206:: with SMTP id x6-v6mr4631305pln.220.1530768753903; Wed, 04 Jul 2018 22:32:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530768753; cv=none; d=google.com; s=arc-20160816; b=Hnp6h9gVGo+7LQxKcI5FD0SqQC/3iMe5T8EdSWCvrw8lZqPURQ7UQdD3jOeiq2sGEu piF6ae5O4F7N+2gta1vHDnktYlLQmwo2H/qqwlcpl/UHiiSPh+yx6uj8LLoHsPkXpShc tWsR/Gyla3m14CPJZnvKgSbE0ILHK7GKPy6dr2x5MILPbjEUWNGuplLLHny0J+6gtMUK Wx+HarDxaRkA8xJiKnhsemdDSVnDREHQx5lPekuPErPIL9zj8/saVXnH5OHMP5Ld7v19 3vdfUDXYL9cXuRoH8d4EwNQbEkl+mcCnr39yiPcdPHmYDwpcmlL6A0ZscBoXyHwuxaz8 EE0w== 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=M4YUxB9cX1diTBF+9Fd3H4s5QmFxt4calo7Z3RNhXtY=; b=f2MilC0rG2CEZXZMcU7M/mB7ILQ6L0JhZ8bZS6dACRymQw8BhMaI+o7Lwmn8OdAYAG 2c3KMde6hJ+oYpXxPs1XFi9hJInmI4PgiuBcWV2965qjNEKbnlulspvammKeu+DMrwHV c800y++CxXf9SZpNwBIYKcBLpEmmuDBQy9gfmyLdr0zKKKkAg7X18uZ/x8Q1c8Q/Vrrf /wxxGdHhl9gt/z7SoZ2KLt27msb311ek9Vi6ZXnaW76mwzAH5Xof+s46ZkDFWMcNIP68 6/uABWV55p9GCOuSahLv6iHqZqlyemE/q9cfI9Dexl3/RlhMCspZmjuugwTde0CKQzbS 1Ycw== 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 124-v6si4728116pgi.425.2018.07.04.22.32.19; Wed, 04 Jul 2018 22:32:33 -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 S1753738AbeGEFaY (ORCPT + 99 others); Thu, 5 Jul 2018 01:30:24 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:49108 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751811AbeGEFaW (ORCPT ); Thu, 5 Jul 2018 01:30:22 -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 1fawqJ-0003Ck-I6; Thu, 05 Jul 2018 07:30:11 +0200 Date: Thu, 5 Jul 2018 07:30:11 +0200 (CEST) From: Thomas Gleixner To: "Yang, Bin" cc: "mingo@kernel.org" , "hpa@zytor.com" , "linux-kernel@vger.kernel.org" , "peterz@infradead.org" , "x86@kernel.org" Subject: Re: [PATCH] x86/mm: fix cpu stuck issue in __change_page_attr_set_clr In-Reply-To: Message-ID: References: <1530180340-18593-1-git-send-email-bin.yang@intel.com> <0131cecd5d0456c2a109f4b8bdbfe558389671dd.camel@intel.com> <3224aae1d09788aba687fd7bd9e088f233016fc8.camel@intel.com> <34a76fad5c43c11ce8ceb491537b453d8053bdb2.camel@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, Yang, Bin wrote: Please do not top post. > This is what my new patch tries to improve. > On 04/07/2018, 10:02 PM, "Thomas Gleixner" wrote: > > The check loop itself is stupid as well. Instead of looping in 4K steps > the thing can be rewritten to check for overlapping ranges and then check > explicitely for those. If there is no overlap in the first place the > whole loop thing can be avoided, but that's a pure optimization and needs > more thought than the straight forward and obvious solution to the > problem at hand. Sorry, I don't see in which way your patch would improve the check loop. It tries to avoid the checks for a consecutive invocation of CPA on the same address range, but it does it in a convoluted way instead of doing the obvious. And in no way it does improve the situation when the check needs to be done. Here is the relevant snippet: + if (!do_split_cache && + address_cache >= addr && address_cache < nextpage_addr && + pgprot_val(new_prot) == pgprot_val(old_prot)) { + do_split = do_split_cache; + goto out_unlock; + } That only ever avoids the check loop when: 1) the previous call cleared do_split_cache 2) the address is within the range of the previous call 3) the pgprot_vals match while moving the pgprot_val check and the alignment check _before_ the loop avoids even more pointless invocations of the loop and is obvious and correct without voodoo logic. The check loop is with both your and my variant absolutely the same and it does not get any smarter or more performant when it's entered. That is a totally different change which needs to do the following: if (overlaps_check_regions(address, numpages)) check_overlapping_regions(address, numpages); and that can be done smart without massive looping in 4K steps, but we really want to analyze _first_ whether the checks are just silently fixing up sloppy callers and whether they are needed at all. Thanks, tglx