Received: by 10.223.185.116 with SMTP id b49csp5320869wrg; Wed, 7 Mar 2018 09:47:11 -0800 (PST) X-Google-Smtp-Source: AG47ELu/jKO6E4mUkmSAZrG2W1KXbg1oINuh3VvAAb4nPpWJbJOP2gLVIjt3JhAGqaXEj18wTFsx X-Received: by 10.99.109.70 with SMTP id i67mr18861358pgc.190.1520444831064; Wed, 07 Mar 2018 09:47:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520444831; cv=none; d=google.com; s=arc-20160816; b=iD5rzOpYDNxHh0LZddH+Wl4sGMWAJ7uiTHZdcb4WUUf4O9PuyJGRtfB/eA+pFTDIEe CYiOiIFokCeFf0gtBugWSwlj1SKujcXxvCr6itFvnAH9vFzYMVRrcxnM+VuKFAtqbx/4 +UN90LFD5EhHoJGYgkqW9Y0nekCE5W0qVvHaVcRI8TSwMlr8ndKqn+SdCwWAAc5DlXmA KAlgq/z+DQyoffS83wQ/EKDYG+wJYUVJXg4YtV4AryS/rGO/Kt6KOcZnPzzQcy3CKbc3 KqUAJb279710Z6u3eHxJLSrTGuxBK6pCWa/vEaDixtOhUPasPlf1jvejSVpur5GVhWK0 ojmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:from:cc:to:subject :content-transfer-encoding:mime-version:references:in-reply-to :user-agent:date:arc-authentication-results; bh=TKLDVWL+uYzUSpxKT5aepFaIZfzbkOuG0z3wnszk/0E=; b=C32+sQ7FNwYyDa08MJldDgzCCsCGC8ZLaBF3xPOkNU6mMvv+w9oKAVWmBVVzxRLPw8 iOZhmmRhfN3o/El/A3UCX3sXeVCSqD520MLxKKZOUxNmtuEoisPWqrqqKTnWqtZRtgRI sd70rUjtU7KGnJQAOM/aNUCsTzLW5nR6WwMAuCdNnZv7VOgvcoQ01wCuA46Vm4c4SlJH g1Iku8MJnQQOCvFsXczBeROxDVGTVtCgbyLSKhnwQ17Qri1FJzzQJs7WDV2x9dHbVEiB YyIatiIzNQQmQN+OppfEUiHLNWoIJ/doRRYgrGJ3Kt8OVK0L57yPagynXU1Uo5f+O6Pz +DlA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v61-v6si13212813plb.698.2018.03.07.09.46.56; Wed, 07 Mar 2018 09:47:11 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933743AbeCGRol convert rfc822-to-8bit (ORCPT + 99 others); Wed, 7 Mar 2018 12:44:41 -0500 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34130 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933412AbeCGRoi (ORCPT ); Wed, 7 Mar 2018 12:44:38 -0500 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w27HiMSR132893 for ; Wed, 7 Mar 2018 12:44:37 -0500 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2gjhcet39t-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Wed, 07 Mar 2018 12:44:37 -0500 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 7 Mar 2018 17:44:34 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 7 Mar 2018 17:44:31 -0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w27HiVtF51577056; Wed, 7 Mar 2018 17:44:31 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45AC04C058; Wed, 7 Mar 2018 17:37:53 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07DE64C046; Wed, 7 Mar 2018 17:37:53 +0000 (GMT) Received: from [9.148.207.13] (unknown [9.148.207.13]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 7 Mar 2018 17:37:52 +0000 (GMT) Date: Wed, 07 Mar 2018 19:44:28 +0200 User-Agent: K-9 Mail for Android In-Reply-To: <54e95716-9d61-51a3-9ae8-196e60625b76@huawei.com> References: <20180228200620.30026-1-igor.stoppa@huawei.com> <20180228200620.30026-2-igor.stoppa@huawei.com> <20180306131856.GD19349@rapoport-lnx> <54e95716-9d61-51a3-9ae8-196e60625b76@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Subject: Re: [PATCH 1/7] genalloc: track beginning of allocations To: Igor Stoppa CC: david@fromorbit.com, willy@infradead.org, keescook@chromium.org, mhocko@kernel.org, labbott@redhat.com, linux-security-module@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com From: Mike Rapoprt X-TM-AS-GCONF: 00 x-cbid: 18030717-0020-0000-0000-000003FFEC81 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18030717-0021-0000-0000-000042942F21 Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-03-07_08:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1803070203 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On March 7, 2018 4:48:25 PM GMT+02:00, Igor Stoppa wrote: > > >On 06/03/18 15:19, Mike Rapoport wrote: >> On Wed, Feb 28, 2018 at 10:06:14PM +0200, Igor Stoppa wrote: > >[...] > >> If I'm not mistaken, several kernel-doc descriptions are duplicated >now. >> Can you please keep a single copy? ;-) > >What's the preferred approach? >Document the functions that are API in the .h file and leave in the .c >those which are not API? I aggree with Matthew: "we usually recommend putting it with the definition so it's more likely to be updated." I couldn't find the doc with this recommendation, though :) >[...] > >>> + * The alignment at which to perform the research for sequence of >empty >> >> ^ search? > >yes > >>> + * get_boundary() - verifies address, then measure length. >> >> There's some lack of consistency between the name and implementation >and >> the description. >> It seems that it would be simpler to actually make it get_length() >and >> return the length of the allocation or nentries if the latter is >smaller. >> Then in gen_pool_free() there will be no need to recalculate nentries >> again. > >There is an error in the documentation. I'll explain below. > >> >>> * @map: pointer to a bitmap >>> - * @start: a bit position in @map >>> - * @nr: number of bits to set >>> + * @start_entry: the index of the first entry in the bitmap >>> + * @nentries: number of entries to alter >> >> Maybe: "maximal number of entries to check"? > >No, it's actually the total number of entries in the chunk. > >[...] > >>> + return nentries - start_entry; >> >> Shouldn't it be "nentries + start_entry"? > >And in the light of the correct comment, also what I am doing should be >now more clear: > >* start_entry is the index of the initial entry >* nentries is the number of entries in the chunk > >If I iterate over the rest of the chunk: > >(i = start_entry + 1; i < nentries; i++) > >without finding either another HEAD or an empty slot, then it means I >was measuring the length of the last allocation in the chunk, which was >taking up all the space, to the end. > >Simple example: > >- chunk with 7 entries -> nentries is 7 >- start_entry is 2, meaning that the last allocation starts from the >3rd >element, iow it occupies indexes from 2 to 6, for a total of 5 entries >- so the length is (nentries - start_entry) = (7 - 2) = 5 > > >But yeah, the kerneldoc was wrong. > >[...] > >>> - * gen_pool_alloc_algo - allocate special memory from the pool >>> + * gen_pool_alloc_algo() - allocate special memory from the pool >> >> + using specified algorithm > >ok > >> >>> * @pool: pool to allocate from >>> * @size: number of bytes to allocate from the pool >>> * @algo: algorithm passed from caller >>> @@ -285,14 +502,18 @@ EXPORT_SYMBOL(gen_pool_alloc); >>> * Uses the pool allocation function (with first-fit algorithm by >default). >> >> "uses the provided @algo function to find room for the allocation" > >ok > >-- >igor -- Sincerely yours, Mike.