Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756753Ab3DWRYH (ORCPT ); Tue, 23 Apr 2013 13:24:07 -0400 Received: from mail-qa0-f45.google.com ([209.85.216.45]:34622 "EHLO mail-qa0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756542Ab3DWRYG (ORCPT ); Tue, 23 Apr 2013 13:24:06 -0400 MIME-Version: 1.0 In-Reply-To: References: <20130422142218.GA26760@mwanda> Date: Tue, 23 Apr 2013 13:24:04 -0400 Message-ID: Subject: Re: [BUG] staging: android: ashmem: Deadlock during ashmem_shrink From: Robert Love To: Shankar Brahadeeswaran Cc: Dan Carpenter , LKML , Bjorn Bringert , Al Viro , devel@driverdev.osuosl.org, Hugh Dickins , Greg Kroah-Hartman , Anjana V Kumar Content-Type: multipart/mixed; boundary=20cf3074b44ab84dd004db0a73b3 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2228 Lines: 46 --20cf3074b44ab84dd004db0a73b3 Content-Type: text/plain; charset=UTF-8 On Tue, Apr 23, 2013 at 12:20 PM, Shankar Brahadeeswaran wrote: > I'm unable to think of a straight forward way to fix this. If you have > any suggestions please provide the same. > If we are unable to solve this too with minor mods, as suggested by > Dan we have to re-look at the locking in this driver. This doesn't look insurmountable. It isn't necessary AFAICT to hold ashmem_mutex across shmem_file_setup. Patch attached (untested). Robert --20cf3074b44ab84dd004db0a73b3 Content-Type: application/octet-stream; name="ashmem-lock-fix.patch" Content-Disposition: attachment; filename="ashmem-lock-fix.patch" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hfvcegkq0 SXQgaXNuJ3QgbmVjZXNzYXJ5IHRvIGhvbGQgYXNobWVtX211dGV4IGFjcm9zcyBzaG1lbV9maWxl X3NldHVwLgoKIGFzaG1lbS5jIHwgICAgNSArKysrLQogMSBmaWxlIGNoYW5nZWQsIDQgaW5zZXJ0 aW9ucygrKSwgMSBkZWxldGlvbigtKQoKU2lnbmVkLW9mZi1ieTogUm9iZXJ0IExvdmUgPHJsb3Zl QHJsb3ZlLm9yZz4KCi0tLSBsaW51eC1iYXNlL2RyaXZlcnMvc3RhZ2luZy9hbmRyb2lkL2FzaG1l bS5jCTIwMTMtMDQtMjMgMTM6MTg6MDUuODAzNzEzNjc4IC0wNDAwCisrKyBsaW51eC9kcml2ZXJz L3N0YWdpbmcvYW5kcm9pZC9hc2htZW0uYwkyMDEzLTA0LTIzIDEzOjIwOjI2Ljg4MzIzODExMCAt MDQwMApAQCAtMzAwLDEyICszMDAsMTUgQEAKIAlpZiAoIWFzbWEtPmZpbGUpIHsKIAkJY2hhciAq bmFtZSA9IEFTSE1FTV9OQU1FX0RFRjsKIAkJc3RydWN0IGZpbGUgKnZtZmlsZTsKKwkJbG9mZl90 IHNpemUgPSBhc21hLT5zaXplOwogCiAJCWlmIChhc21hLT5uYW1lW0FTSE1FTV9OQU1FX1BSRUZJ WF9MRU5dICE9ICdcMCcpCiAJCQluYW1lID0gYXNtYS0+bmFtZTsKIAogCQkvKiAuLi4gYW5kIGFs bG9jYXRlIHRoZSBiYWNraW5nIHNobWVtIGZpbGUgKi8KLQkJdm1maWxlID0gc2htZW1fZmlsZV9z ZXR1cChuYW1lLCBhc21hLT5zaXplLCB2bWEtPnZtX2ZsYWdzKTsKKwkJbXV0ZXhfdW5sb2NrKCZh c2htZW1fbXV0ZXgpOworCQl2bWZpbGUgPSBzaG1lbV9maWxlX3NldHVwKG5hbWUsIHNpemUsIHZt YS0+dm1fZmxhZ3MpOworCQltdXRleF9sb2NrKCZhc2htZW1fbXV0ZXgpOwogCQlpZiAodW5saWtl bHkoSVNfRVJSKHZtZmlsZSkpKSB7CiAJCQlyZXQgPSBQVFJfRVJSKHZtZmlsZSk7CiAJCQlnb3Rv IG91dDsK --20cf3074b44ab84dd004db0a73b3-- -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/