Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1435036lqj; Tue, 4 Jun 2024 01:03:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXml9ukkVxbIGHcs1U1n4t/2bez4gUGHcMiwCtiws28mhMcM9OahO9EgAFY6d8OXIQjI1AG6ZIHpecfupwL8KQgqK6NDR3M+mzXszAQOw== X-Google-Smtp-Source: AGHT+IHYx+oRczsCU4i+uWx6ebUiodQ4+14NB96ZlCxbU2BIwRE3J47/aaSsU77vGMldt5gxj+2O X-Received: by 2002:a17:902:e886:b0:1f4:8bb9:924f with SMTP id d9443c01a7336-1f6936ab828mr26743195ad.1.1717488219796; Tue, 04 Jun 2024 01:03:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717488219; cv=pass; d=google.com; s=arc-20160816; b=m0OIsDaviTmgPdVWknJTL0mFWV5e+02oVWAbXE7Qm97ndTVG9RSDolU3R28RVL6CW4 LPejrr2UfnfArHZKWlFRa9/6FtqkUrKjmzhjztWfKflzlSBk+AlIyROGCZDPIr9XflgU gEfk4nt+BrSK31r1aNqvCMlo5BtgWrbXwiF2sqWhuhT9JkAGwbqF8eSl6s5jYH2J21cQ +Xoi7P2cwEMmbpEUO2kzaKpcJtKbeBUc9VWX0/13QDQAAJGnXxrUcITl97xOH9/DcqV8 Gjgt/jBi/mCfpw7DL9WuWbl4UeokO0C9G1bicAhSdKlwdEV4o5SKu32FCXltYoBi7PyC gJAw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=/2h304tkOJFnFlQMxg3EG6MI/HuME1XtmAEkjVrYmYY=; fh=PRUQZ6BLVU3+w6HfpR/z01+X40Xq3yJuNVhLY5x9394=; b=wbWcJyUrC31tT1S3NtQuSBlD7bylxcJWMZBzQxLkw/cyBW/9cQtQHacaFtTGrJzJyq rpW6CmyoiJAHjV1OQZJA/4p9KlMKIZMfLGmbIESjYJvyCAA8XNU4KR58dbIjFDPidQ0F TcKM8UtUTkVlVfQd8gSaCD5UIEp4ei+GxcpMhbye7nXyju9VvYETS99I84lnJCCG22gc xVUMyrK9xOI3h1VfQvNU+d/VfHFzY5ccmSA+A9mibQ76Dl0K8ox2tq74NA6h1nA30uXv ONP8UshdK1MfWGWvnvvEQhGSzlUMN2/nD/6Wesb+Otu2193gLItes9CVhIDIeR792AlH xgow==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FfoLU4/R"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200206-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f67c7640d3si2213585ad.387.2024.06.04.01.03.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 01:03:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200206-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="FfoLU4/R"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200206-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200206-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id BD3C6B21F76 for ; Tue, 4 Jun 2024 07:59:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0BFF91422B5; Tue, 4 Jun 2024 07:58:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="FfoLU4/R" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 26C1C1411CA; Tue, 4 Jun 2024 07:58:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717487932; cv=none; b=W8CQCf4UfAgvqjazmH9a6QJDs9pRVaFxaSYGZAVjWzXArM/Jk2xETux6Q8cuGc1txXcfL9Y6OKIPfczvgsOfQJlH5iX35aPPE13epxcbmyFSWZkXM3nv4ayZdyXK1+zcVUQsfNSaokJ3SAVkDrDGYDsEpWUlq6fjeVNSGoEECjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717487932; c=relaxed/simple; bh=/2h304tkOJFnFlQMxg3EG6MI/HuME1XtmAEkjVrYmYY=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=KirDxwB7PqVAHrXXDd4njxY8p2ws3bKXUVvohxGSdD9W4w4jNCPIuLbmqhJO4uVKXnCq8dLAsO9VT7nQSxqUFoyzNFlLZ0YJ8Hgz3zUdYCo9+1YHbX4/wLAomUdS80ueUjJPMjNUG0R5U2ST0oxCGakCRw4ffD9AXlht3g+egTI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=FfoLU4/R; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AD1BC2BBFC; Tue, 4 Jun 2024 07:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717487931; bh=/2h304tkOJFnFlQMxg3EG6MI/HuME1XtmAEkjVrYmYY=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=FfoLU4/Rw1RAUN1Ww+rsMTdeA1C0zktNuV7DVFFartqRjRUWC72cr6+Iy8lTssqya +F9a+yR0qD35AhleNxWSrCKwRqj112IL6hJtu7SN0pvYuoausgWlbDsjBM4GGFoQO9 mkPiHgXe/i353/szgViaRzUHEynzpTy5bqFzRNrFAECPI5X1f9Amqjmig4ejTuEZjm KxMtnaQOGdCBMLovnIR5LmiJcnKtxEjs0tZKwwNSDITcekKklMDG0Q75SzDmMp+kBX q7axmSh2tcDoBilsNvWT8y3vYTZQgfBU7u81KJ2G6E2noenkiwErbF/Be22Cj1W6uH 9EqqHakY8rM2A== Date: Tue, 4 Jun 2024 09:58:48 +0200 (CEST) From: Jiri Kosina To: "Hailong.Liu" cc: benjamin.tissoires@redhat.com, linux-input@vger.kernel.org, linux-kernel@vger.kernel.org, 21cnbao@gmail.com Subject: Re: [PATCH] HID: Use kvzalloc instead of kzalloc in hid_register_field() In-Reply-To: <20240522080328.12317-1-hailong.liu@oppo.com> Message-ID: References: <20240522080328.12317-1-hailong.liu@oppo.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Wed, 22 May 2024, hailong.liu@oppo.com wrote: > From: "Hailong.Liu" >=20 > The function hid_register_field() might allocate more than 32k, which > would use order-4 contiguous memory if the parameter usage exceeds > 1024. However, after the system runs for a while, the memory can > become heavily fragmented. This increases the likelihood of order-4 page > allocation failure. Here=E2=80=99s the relevant log. >=20 > [71553.093623]kworker/1: 0: page allocation failure: order:4, mode:0x40dc= 0(GFP_KERNEL|__GFP_COMP|__GFP_ZERO), nodemask=3D(null),cpuset=3D/,mems_allo= wed=3D0 > [71553.093669]Workqueue: events uhid_device_add_worker > [71553.093683]Call trace: > [71553.093687]: dump_backtrace+0xf4/0x118 > [71553.093696]: show_stack+0x18/0x24 > [71553.093702]: dump_stack_lvl+0x60/0x7c > [71553.093710]: dump_stack+0x18/0x3c > [71553.093717]: warn_alloc+0xf4/0x174 > [71553.093725]: __alloc_pages_slowpath+0x1ba0/0x1cac > [71553.093732]: __alloc_pages+0x460/0x560 > [71553.093738]: __kmalloc_large_node+0xbc/0x1f8 > [71553.093746]: __kmalloc+0x144/0x254 > [71553.093752]: hid_add_field+0x13c/0x308 > [71553.093758]: hid_parser_main+0x250/0x298 > [71553.093765]: hid_open_report+0x214/0x30c > [71553.093771]: mt_probe+0x130/0x258 > [71553.093778]: hid_device_probe+0x11c/0x1e4 > [71553.093784]: really_probe+0xe4/0x388 > [71553.093791]: __driver_probe_device+0xa0/0x12c > [71553.093798]: driver_probe_device+0x44/0x214 > [71553.093804]: __device_attach_driver+0xdc/0x124 > [71553.093812]: bus_for_each_drv+0x88/0xec > [71553.093818]: __device_attach+0x84/0x170 > [71553.093824]: device_initial_probe+0x14/0x20 > [71553.093831]: bus_probe_device+0x48/0xd0 > [71553.093836]: device_add+0x248/0x928 > [71553.093844]: hid_add_device+0xf8/0x1a4 > [71553.093850]: uhid_device_add_worker+0x24/0x144 > [71553.093857]: process_one_work+0x158/0x804 > [71553.093865]: worker_thread+0x15c/0x494 > [71553.093872]: kthread+0xf4/0x1e4 > [71553.093880]: ret_from_fork+0x10/0x20 >=20 > To fix the allocation failure, use kvzalloc() instead of kzalloc(). >=20 > Signed-off-by: Hailong.Liu Applied, thanks. --=20 Jiri Kosina SUSE Labs