From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752831AbcAGLOb (ORCPT ); Thu, 7 Jan 2016 06:14:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54730 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751193AbcAGLO3 (ORCPT ); Thu, 7 Jan 2016 06:14:29 -0500 Subject: Re: [PATCH v2 2/2] kexec: Provide arch_kexec_protect(unprotect)_crashkres() To: Petr Tesarik References: <1452073845-1474-1-git-send-email-xlpang@redhat.com> <1452073845-1474-2-git-send-email-xlpang@redhat.com> <20160106170832.GB25832@dhcp-128-25.nay.redhat.com> <568DC9F0.8090609@redhat.com> <20160107023637.GA12526@dhcp-128-25.nay.redhat.com> <568DF2C5.9080701@redhat.com> <20160107102041.1d99f70f@hananiah.suse.cz> Cc: Minfei Huang , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, ebiederm@xmission.com, akpm@linux-foundation.org, Dave Young , Vivek Goyal From: Xunlei Pang Message-ID: <568E488C.8090907@redhat.com> Date: Thu, 7 Jan 2016 19:14:20 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20160107102041.1d99f70f@hananiah.suse.cz> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/07/2016 at 05:20 PM, Petr Tesarik wrote: > On Thu, 7 Jan 2016 13:08:21 +0800 > Xunlei Pang wrote: > >> On 01/07/2016 at 10:36 AM, Minfei Huang wrote: >>> On 01/07/16 at 10:14am, Xunlei Pang wrote: >>>>>> +static int >>>>>> +kexec_mark_range(unsigned long start, unsigned long end, bool protect) >>>>>> +{ >>>>>> + struct page *page; >>>>>> + unsigned int nr_pages; >>>>>> + >>>>>> + /* For physical range: [start, end] */ >>>>>> + if (!start || !end || start > end) >>>>>> + return 0; >>>>> Hi, Xunlei. >>>>> >>>>> if (start > end) >>>>> return 0; >>>> If both start and end are zero, we want to return directly, so the two >>>> more check doesn't hurt. >>> How about if the start is equal to 0, and end is larger than 0? It is >>> better to make code more robust, although it never happen in currect >>> kexec code. >> Hmm, this will be better: >> >> if (!end || start > end) >> return 0; >> >> it handles the common case not using crash_low_res(start and end are 0). > Hm, if both start and end are 0, then what about using this condition: > > if (start >= end) > return 0; > > I think it's good enough, because if start is equal to end, then > there's nothing to protect anyway. In theory, start==end(not 0) still means we have 1B to protect :-) But in practice there are no such cases, so I think this is ok. Regards, Xunlei > > Regards, > Petr Tesarik > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec