Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1261804ybl; Fri, 23 Aug 2019 16:26:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXPDyGrGBuatwQT28sdsg42kdGZBqReiDfw+QXlra36bwnoy7zrwlltJOAchlL6gK+AqPL X-Received: by 2002:a63:bf01:: with SMTP id v1mr5926944pgf.278.1566602786062; Fri, 23 Aug 2019 16:26:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566602786; cv=none; d=google.com; s=arc-20160816; b=Oj5oSmuF0GkfX5BKKDCf4zt2URmzmOJtYTDQcX6X6b/sglAT8tFjSeAHW3KiC/Xwmh INgOdmNMw6vKs2PiwmEOxYjV5vbilYOGYYZIIU3PdIBTXE+OKxkrNP38O0TK6QC4iIpu hk1v7ebmrrFg6aHtdHmbAKYewWcQ/4l4K9Xk6NMWito72zp6E+m1WlFCSFIzCfPT4p94 FGTQzxZymtpam6OCQIkyq7tlPQxmK1uTVyykx4roEuKt/SE8ZXb01qkhwZdEMUSPPDaR p6JCvaTPqOJbe/pjHLIeWKnDaZegcbZxQipt0Uy5EXkZCNqKmJe6fT/yh4rCS63Prr+C CbFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=TlgSQbGZQbJS6HSDwi/9wyBYZmrJdjzuU/XfSgcoVhk=; b=qSoDd3DzW5shEru9GAn+SOYuDiEXXLPBzw4giUyVWlrc0g337BdAXqPht89gXu4S5i OuQ2cDkL0lkJ3b0+Wq84J+MJAzVb4OsAwKau59B+NIZG07pT3ypvVjQbQrADc7QMjJar NoVvO5usHAOd9nXZG6OgErGqpe1Ke9ov/o9mod0zmU9lsgbYqHaS0kvqo5nIPvcKI82e 9U10psVtgasQ1SWMA0btQDjzBMpVk6I8TYhzYVxaxZd8kBhaLK4OePj759xAAIJ7URtz AMdMS6VtRkxZMTcpNkJaANnRauHlL90mWbQKUx02W3qlyndtLlLPFPBqB8DMNJsUSCGz dOjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZjSOzcnG; 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 24si2959613pgu.501.2019.08.23.16.26.11; Fri, 23 Aug 2019 16:26:26 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=ZjSOzcnG; 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 S2390789AbfHWOCy (ORCPT + 99 others); Fri, 23 Aug 2019 10:02:54 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:37764 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389723AbfHWOCx (ORCPT ); Fri, 23 Aug 2019 10:02:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=TlgSQbGZQbJS6HSDwi/9wyBYZmrJdjzuU/XfSgcoVhk=; b=ZjSOzcnGcfW/LTdzeR/cMRrGu hM5Ku9PVLtYuui8pFAfhIb6v0R6YOO5qjsMuw7dvWVbFpD+i5Z5PqZ9ahOHejsSTlE9wrd+apSRUZ 1r1B6ol8fjseEyO1nHBCb4O2rZ9vMWpl2zedqIxRFO1cadKFaGAE9Y1lH/npc5yz38/ld/lub0fE/ DC9LG7mINAvxT7HwTNVePM1CgJxvR+bPTXgQgq9bjLe4pZylvKfJQBGc0hX4lCccOU3PI2F1F0e6d OWGqm8f1dndYs52YG854QIFZs9ZzNF/Prwi1z8CqHiUww9N5xeH+mB6o5TaLm7HcIvoIVnvkAMFJ0 c1zcqv41Q==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by bombadil.infradead.org with esmtpsa (Exim 4.92 #3 (Red Hat Linux)) id 1i1A9E-0006Qi-4s; Fri, 23 Aug 2019 14:02:36 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 415B1305F65; Fri, 23 Aug 2019 16:02:01 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id A4044202245EA; Fri, 23 Aug 2019 16:02:33 +0200 (CEST) Date: Fri, 23 Aug 2019 16:02:33 +0200 From: Peter Zijlstra To: Yu-cheng Yu Cc: x86@kernel.org, "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-api@vger.kernel.org, Arnd Bergmann , Andy Lutomirski , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Randy Dunlap , "Ravi V. Shankar" , Vedvyas Shanbhogue , Dave Martin Subject: Re: [PATCH v8 11/27] x86/mm: Introduce _PAGE_DIRTY_SW Message-ID: <20190823140233.GC2332@hirez.programming.kicks-ass.net> References: <20190813205225.12032-1-yu-cheng.yu@intel.com> <20190813205225.12032-12-yu-cheng.yu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190813205225.12032-12-yu-cheng.yu@intel.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 13, 2019 at 01:52:09PM -0700, Yu-cheng Yu wrote: > +static inline pte_t pte_move_flags(pte_t pte, pteval_t from, pteval_t to) > +{ > + if (pte_flags(pte) & from) > + pte = pte_set_flags(pte_clear_flags(pte, from), to); > + return pte; > +} Aside of the whole conditional thing (I agree it would be better to have this unconditionally); the function doesn't really do as advertised. That is, if @from is clear, it doesn't endeavour to make sure @to is also clear. Now it might be sufficient, but in that case it really needs a comment and or different name. An implementation that actually moves the bit is something like: pteval_t a,b; a = native_pte_value(pte); b = (a >> from_bit) & 1; a &= ~((1ULL << from_bit) | (1ULL << to_bit)); a |= b << to_bit; return make_native_pte(a);