From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752913AbcAGJUu (ORCPT ); Thu, 7 Jan 2016 04:20:50 -0500 Received: from mx2.suse.de ([195.135.220.15]:44634 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751910AbcAGJUq (ORCPT ); Thu, 7 Jan 2016 04:20:46 -0500 Date: Thu, 7 Jan 2016 10:20:41 +0100 From: Petr Tesarik To: Xunlei Pang Cc: Minfei Huang , kexec@lists.infradead.org, linux-kernel@vger.kernel.org, ebiederm@xmission.com, akpm@linux-foundation.org, Dave Young , Vivek Goyal Subject: Re: [PATCH v2 2/2] kexec: Provide arch_kexec_protect(unprotect)_crashkres() Message-ID: <20160107102041.1d99f70f@hananiah.suse.cz> In-Reply-To: <568DF2C5.9080701@redhat.com> 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> Organization: SUSE Linux, s.r.o. X-Mailer: Claws Mail 3.11.0 (GTK+ 2.24.28; x86_64-suse-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Petr Tesarik